Class: AdminSet
- Inherits:
-
ActiveFedora::Base
- Object
- ActiveFedora::Base
- AdminSet
- Includes:
- Hydra::AccessControls::WithAccessRight, Hyrax::HasRepresentative, Hyrax::HumanReadableType, Hyrax::Noid
- Defined in:
- app/models/admin_set.rb
Overview
There is an interplay between an AdminSet and a PermissionTemplate. Given that AdminSet is an ActiveFedora::Base and PermissionTemplate is ActiveRecord::Base we don’t have the usual :has_many or :belongs_to methods to assist in defining that relationship. However, from a conceptual standpoint:
-
An AdminSet has_one :permission_tempate
-
A PermissionTemplate belongs_to :admin_set
When an object is added as a member of an AdminSet, the AdminSet’s associated PermissionTemplate is applied to that object (e.g. some of the object’s attributes are updated as per the rules of the permission template)
Constant Summary collapse
- DEFAULT_ID =
'admin_set/default'.freeze
- DEFAULT_TITLE =
['Default Admin Set'].freeze
- DEFAULT_WORKFLOW_NAME =
Hyrax.config.default_active_workflow_name
Class Method Summary collapse
- .default_set?(id) ⇒ Boolean
-
.find_or_create_default_admin_set_id ⇒ Object
Creates the default AdminSet and an associated PermissionTemplate with workflow.
Instance Method Summary collapse
- #active_workflow ⇒ Sipity::Workflow
- #default_set? ⇒ Boolean
-
#permission_template ⇒ Hyrax::PermissionTemplate
A bit of an analogue for a ‘has_one :admin_set` as it crosses from Fedora to the DB.
-
#reset_access_controls! ⇒ Object
Calculate and update who should have edit access based on who has “manage” access in the PermissionTemplateAccess.
- #to_s ⇒ Object
Methods included from Hyrax::HumanReadableType
#human_readable_type, #to_solr
Methods included from Hyrax::Noid
Class Method Details
.default_set?(id) ⇒ Boolean
49 50 51 |
# File 'app/models/admin_set.rb', line 49 def self.default_set?(id) id == DEFAULT_ID end |
.find_or_create_default_admin_set_id ⇒ Object
Creates the default AdminSet and an associated PermissionTemplate with workflow
58 59 60 61 |
# File 'app/models/admin_set.rb', line 58 def self.find_or_create_default_admin_set_id Hyrax::AdminSetCreateService.create_default_admin_set(admin_set_id: DEFAULT_ID, title: DEFAULT_TITLE) unless exists?(DEFAULT_ID) DEFAULT_ID end |
Instance Method Details
#active_workflow ⇒ Sipity::Workflow
79 80 81 |
# File 'app/models/admin_set.rb', line 79 def active_workflow Sipity::Workflow.find_active_workflow_for(admin_set_id: id) end |
#default_set? ⇒ Boolean
53 54 55 |
# File 'app/models/admin_set.rb', line 53 def default_set? self.class.default_set?(id) end |
#permission_template ⇒ Hyrax::PermissionTemplate
A bit of an analogue for a ‘has_one :admin_set` as it crosses from Fedora to the DB
71 72 73 |
# File 'app/models/admin_set.rb', line 71 def Hyrax::PermissionTemplate.find_by!(source_id: id) end |
#reset_access_controls! ⇒ Object
Calculate and update who should have edit access based on who has “manage” access in the PermissionTemplateAccess
85 86 87 88 89 90 91 92 |
# File 'app/models/admin_set.rb', line 85 def reset_access_controls! # NOTE: This is different from Collections in that it doesn't update read access based on visibility. # See also app/models/concerns/hyrax/collection_behavior.rb#reset_access_controls! update!(edit_users: , edit_groups: , read_users: , read_groups: ) end |
#to_s ⇒ Object
63 64 65 |
# File 'app/models/admin_set.rb', line 63 def to_s title.present? ? title : 'No Title' end |