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
- #add_default_roles ⇒ Object
- #admin_roles ⇒ Object
- #exhibit_roles ⇒ Object
- #invite_pending? ⇒ Boolean
- #superadmin? ⇒ Boolean
- #viewer_roles ⇒ Object
Instance Method Details
#add_default_roles ⇒ Object
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_roles ⇒ Object
29 30 31 |
# File 'app/models/concerns/spotlight/user.rb', line 29 def admin_roles exhibit_roles.where(role: 'admin') end |
#exhibit_roles ⇒ Object
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
39 40 41 |
# File 'app/models/concerns/spotlight/user.rb', line 39 def invite_pending? invited_to_sign_up? && !invitation_accepted? end |
#superadmin? ⇒ 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_roles ⇒ Object
25 26 27 |
# File 'app/models/concerns/spotlight/user.rb', line 25 def viewer_roles roles.where(resource_type: 'Spotlight::Exhibit', role: 'viewer') end |