Module: Spotlight::User

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/spotlight/user.rb

Overview

Spotlight user mixins for roles

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#add_default_rolesObject



33
34
35
36
37
# File 'app/models/concerns/spotlight/user.rb', line 33

def add_default_roles
  return unless Spotlight::Engine.config.assign_default_roles_to_first_user

  roles.build role: 'admin', resource: Spotlight::Site.instance unless self.class.any?
end

#admin_rolesObject



29
30
31
# File 'app/models/concerns/spotlight/user.rb', line 29

def admin_roles
  exhibit_roles.where(role: 'admin')
end

#exhibit_rolesObject



21
22
23
# File 'app/models/concerns/spotlight/user.rb', line 21

def exhibit_roles
  roles.where(resource_type: 'Spotlight::Exhibit').where.not(role: 'viewer')
end

#invite_pending?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'app/models/concerns/spotlight/user.rb', line 39

def invite_pending?
  invited_to_sign_up? && !invitation_accepted?
end

#superadmin?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/models/concerns/spotlight/user.rb', line 17

def superadmin?
  roles.where(role: 'admin', resource: Spotlight::Site.instance).any?
end

#viewer_rolesObject



25
26
27
# File 'app/models/concerns/spotlight/user.rb', line 25

def viewer_roles
  roles.where(resource_type: 'Spotlight::Exhibit', role: 'viewer')
end