Class: Hyrax::PermissionTemplateAccess
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Hyrax::PermissionTemplateAccess
- Defined in:
- app/models/hyrax/permission_template_access.rb
Overview
Models a single grant of access to an agent (user or group) on a PermissionTemplate
Constant Summary collapse
- VIEW =
'view'
- DEPOSIT =
'deposit'
- MANAGE =
'manage'
- GROUP =
'group'
- USER =
'user'
Class Method Summary collapse
-
.for_user(ability:, access:, exclude_groups: []) ⇒ ActiveRecord::Relation
The permissions template access a given user has.
Instance Method Summary collapse
Class Method Details
.for_user(ability:, access:, exclude_groups: []) ⇒ ActiveRecord::Relation
The permissions template access a given user has.
37 38 39 40 41 42 43 44 |
# File 'app/models/hyrax/permission_template_access.rb', line 37 def self.for_user(ability:, access:, exclude_groups: []) PermissionTemplateAccess.where( user_where(access: access, ability: ability) ).or( PermissionTemplateAccess .where(group_where(access: access, ability: ability, exclude_groups: exclude_groups)) ) end |
Instance Method Details
#admin_group? ⇒ Boolean
58 59 60 |
# File 'app/models/hyrax/permission_template_access.rb', line 58 def admin_group? agent_type == GROUP && agent_id == ::Ability.admin_group_name end |
#label ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/models/hyrax/permission_template_access.rb', line 46 def label return agent_id unless agent_type == GROUP case agent_id when 'registered' I18n.t('hyrax.admin.admin_sets.form_participant_table.registered_users') when ::Ability.admin_group_name I18n.t('hyrax.admin.admin_sets.form_participant_table.admin_users') else agent_id end end |