Module: Mumuki::Domain::Helpers::User

Extended by:
ActiveSupport::Concern
Includes:
Mumukit::Auth::Roles, Mumukit::Platform::Notifiable
Included in:
User
Defined in:
lib/mumuki/domain/helpers/user.rb

Instance Method Summary collapse

Instance Method Details

#any_granted_organizationsObject

Accessible organizations



78
79
80
# File 'lib/mumuki/domain/helpers/user.rb', line 78

revamp_accessor :any_granted_organizations, :student_granted_organizations do |_, _, result|
  result.map { |org| Mumukit::Platform::Organization.find_by_name!(org) rescue nil }.compact
end

#discusser_of?(organization) ⇒ Boolean

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

Returns:

  • (Boolean)


47
48
49
# File 'lib/mumuki/domain/helpers/user.rb', line 47

def discusser_of?(organization)
  has_permission? organization.forum_discussions_minimal_role, organization.slug
end

#full_nameObject Also known as: name

Profile



62
63
64
# File 'lib/mumuki/domain/helpers/user.rb', line 62

def full_name
  "#{first_name} #{last_name}".strip
end

#has_immersive_main_organization?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/mumuki/domain/helpers/user.rb', line 90

def has_immersive_main_organization?
  !!main_organization.try(&:immersive?)
end

#has_role?Object

Permissions



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/mumuki/domain/helpers/user.rb', line 8

delegate :has_role?,
:add_permission!,
:remove_permission!,
:has_permission?,
:has_permission_delegation?,
:protect!,
:protect_delegation!,
:protect_permissions_assignment!,
:student_granted_organizations,
:any_granted_organizations,
to: :permissions

#has_student_granted_organizations?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/mumuki/domain/helpers/user.rb', line 82

def has_student_granted_organizations?
  student_granted_organizations.present?
end

#main_organizationObject



86
87
88
# File 'lib/mumuki/domain/helpers/user.rb', line 86

def main_organization
  student_granted_organizations.first || any_granted_organizations.first
end

#merge_permissions!(new_permissions) ⇒ Object



24
25
26
# File 'lib/mumuki/domain/helpers/user.rb', line 24

def merge_permissions!(new_permissions)
  self.permissions = permissions.merge(new_permissions)
end

#platform_class_nameObject



20
21
22
# File 'lib/mumuki/domain/helpers/user.rb', line 20

def platform_class_name
  :User
end

#profile_completed?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/mumuki/domain/helpers/user.rb', line 68

def profile_completed?
  self.class.profile_fields.map { |it| self[it] }.all? &:present?
end

#to_paramObject

API Exposure



96
97
98
# File 'lib/mumuki/domain/helpers/user.rb', line 96

def to_param
  uid
end

#to_sObject



72
73
74
# File 'lib/mumuki/domain/helpers/user.rb', line 72

def to_s
  "#{full_name} <#{email}> [#{uid}]"
end