Module: Hyrax::AdminSetBehavior

Extended by:
ActiveSupport::Concern
Includes:
Hydra::AccessControls::WithAccessRight, HasRepresentative, HumanReadableType, Noid
Included in:
AdminSet
Defined in:
app/models/concerns/hyrax/admin_set_behavior.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)

Instance Method Summary collapse

Methods included from HumanReadableType

#human_readable_type, #to_solr

Methods included from Noid

#assign_id, #to_param

Instance Method Details

#active_workflowSipity::Workflow

Returns:

Raises:

  • (ActiveRecord::RecordNotFound)


87
88
89
# File 'app/models/concerns/hyrax/admin_set_behavior.rb', line 87

def active_workflow
  Sipity::Workflow.find_active_workflow_for(admin_set_id: id)
end

#permission_templateHyrax::PermissionTemplate

A bit of an analogue for a ‘has_one :admin_set` as it crosses from Fedora to the DB

Returns:

Raises:

  • (ActiveRecord::RecordNotFound)


79
80
81
# File 'app/models/concerns/hyrax/admin_set_behavior.rb', line 79

def permission_template
  Hyrax::PermissionTemplate.find_by!(admin_set_id: id)
end

#to_sObject



71
72
73
# File 'app/models/concerns/hyrax/admin_set_behavior.rb', line 71

def to_s
  title.present? ? title : 'No Title'
end

#update_access_controls!Object

Calculate and update who should have edit access based on who has “manage” access in the PermissionTemplateAccess



93
94
95
96
# File 'app/models/concerns/hyrax/admin_set_behavior.rb', line 93

def update_access_controls!
  update!(edit_users: permission_template.agent_ids_for(access: 'manage', agent_type: 'user'),
          edit_groups: permission_template.agent_ids_for(access: 'manage', agent_type: 'group'))
end