Sha256: e8443d37a462cdfd4a7de135fb920339ad5f23779d53924310b2a6bb80dff823
Contents?: true
Size: 1.38 KB
Versions: 36
Compression:
Stored size: 1.38 KB
Contents
module Hyrax class CollectionTypeParticipant < ActiveRecord::Base self.table_name = 'collection_type_participants' belongs_to :hyrax_collection_type, class_name: 'CollectionType', foreign_key: 'hyrax_collection_type_id' MANAGE_ACCESS = 'manage'.freeze CREATE_ACCESS = 'create'.freeze GROUP_TYPE = 'group'.freeze USER_TYPE = 'user'.freeze validates :agent_id, presence: true validates :agent_type, presence: true, inclusion: { in: [GROUP_TYPE, USER_TYPE], message: "%<value>s is not a valid agent type. Accepts: #{GROUP_TYPE}, #{USER_TYPE}" } validates :access, presence: true, inclusion: { in: [MANAGE_ACCESS, CREATE_ACCESS], message: "%<value>s is not a valid access. Accepts: #{MANAGE_ACCESS}, #{CREATE_ACCESS}" } validates :hyrax_collection_type_id, presence: true def manager? access == MANAGE_ACCESS end def creator? access == CREATE_ACCESS end def label return agent_id unless agent_type == GROUP_TYPE case agent_id when ::Ability.registered_group_name 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 end end
Version data entries
36 entries across 36 versions & 1 rubygems