module Mumuki::Domain::Helpers::User

Public Instance Methods

discusser_of?(organization) click to toggle source

Tells whether this user has forum discusser permissions in the given organization

# File lib/mumuki/domain/helpers/user.rb, line 49
def discusser_of?(organization)
  has_permission? organization.forum_discussions_minimal_role, organization.slug
end
has_immersive_main_organization?() click to toggle source

Deprecated: use `immersive_organization_at` which properly looks for a single immersive organization taking current organization and path into account

# File lib/mumuki/domain/helpers/user.rb, line 89
def has_immersive_main_organization?
  main_organization.try(&:immersive?).present?
end
has_student_granted_organizations?() click to toggle source
# File lib/mumuki/domain/helpers/user.rb, line 78
def has_student_granted_organizations?
  student_granted_organizations.present?
end
immersive_organization_at(path_item, current = Organization.current) click to toggle source
# File lib/mumuki/domain/helpers/user.rb, line 93
def immersive_organization_at(path_item, current = Organization.current)
  immersive_organizations_at(path_item, current).single
end
immersive_organization_with_content_at(path_item, current = Organization.current) click to toggle source
# File lib/mumuki/domain/helpers/user.rb, line 102
def immersive_organization_with_content_at(path_item, current = Organization.current)
  orga = immersive_organizations_with_content_at(path_item, current).single
  [orga, path_item&.navigable_content_in(orga)]
end
immersive_organizations_at(path_item, current = Organization.current) click to toggle source
# File lib/mumuki/domain/helpers/user.rb, line 97
def immersive_organizations_at(path_item, current = Organization.current)
  usage_filter = path_item ? lambda { |it| path_item.used_in?(it) } : lambda { |_| true }
  immersive_organizations_for(current).select(&usage_filter)
end
immersive_organizations_with_content_at(path_item, current = Organization.current) click to toggle source
# File lib/mumuki/domain/helpers/user.rb, line 107
def immersive_organizations_with_content_at(path_item, current = Organization.current)
  immersive_without_usage = immersive_organizations_for(current)
  return immersive_without_usage unless path_item.present?

  immersive_with_usage = immersive_without_usage.select { |it| path_item.content_used_in? it }
  immersive_with_usage.empty? ? immersive_without_usage : immersive_with_usage
end
main_organization() click to toggle source
# File lib/mumuki/domain/helpers/user.rb, line 82
def main_organization
  student_granted_organizations.first || any_granted_organizations.first
end
merge_permissions!(new_permissions) click to toggle source
# File lib/mumuki/domain/helpers/user.rb, line 26
def merge_permissions!(new_permissions)
  self.permissions = permissions.merge(new_permissions)
end
platform_class_name() click to toggle source
# File lib/mumuki/domain/helpers/user.rb, line 22
def platform_class_name
  :User
end
profile_completed?() click to toggle source

Profile

# File lib/mumuki/domain/helpers/user.rb, line 64
def profile_completed?
  self.class.profile_fields.map { |it| self[it] }.all? &:present?
end
profile_fields() click to toggle source
# File lib/mumuki/domain/helpers/user.rb, line 122
def profile_fields
  [:first_name, :last_name, :gender, :birthdate]
end
to_param() click to toggle source

API Exposure

# File lib/mumuki/domain/helpers/user.rb, line 117
def to_param
  uid
end
to_s() click to toggle source
# File lib/mumuki/domain/helpers/user.rb, line 68
def to_s
  "#{full_name} <#{email}> [#{uid}]"
end

Private Instance Methods

immersive_organizations_for(organization) click to toggle source
# File lib/mumuki/domain/helpers/user.rb, line 129
def immersive_organizations_for(organization)
  return [] unless organization.immersible?

  student_granted_organizations.select { |it| organization.immersed_in?(it) }
end