Sha256: 971a4bde03f14a7244f1c8b7f9ba324ee7073c5eb9ce1bd5e6f9679554ca3cf3

Contents?: true

Size: 1.09 KB

Versions: 12

Compression:

Stored size: 1.09 KB

Contents

module Hyrax
  module Actors
    # Responsible for "applying" the various edit and read attributes to the given curation concern.
    # @see Hyrax::AdminSetService for release_date interaction
    class ApplyPermissionTemplateActor < Hyrax::Actors::AbstractActor
      # @param [Hyrax::Actors::Environment] env
      # @return [Boolean] true if create was successful
      def create(env)
        add_edit_users(env)
        next_actor.create(env)
      end

      private

        def add_edit_users(env)
          return if env.attributes[:admin_set_id].blank?
          template = Hyrax::PermissionTemplate.find_by!(admin_set_id: env.attributes[:admin_set_id])
          env.curation_concern.edit_users += template.agent_ids_for(agent_type: 'user', access: 'manage')
          env.curation_concern.edit_groups += template.agent_ids_for(agent_type: 'group', access: 'manage')
          env.curation_concern.read_users += template.agent_ids_for(agent_type: 'user', access: 'view')
          env.curation_concern.read_groups += template.agent_ids_for(agent_type: 'group', access: 'view')
        end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hyrax-2.0.3 app/actors/hyrax/actors/apply_permission_template_actor.rb
hyrax-2.0.2 app/actors/hyrax/actors/apply_permission_template_actor.rb
hyrax-2.0.1 app/actors/hyrax/actors/apply_permission_template_actor.rb
hyrax-2.0.0 app/actors/hyrax/actors/apply_permission_template_actor.rb
hyrax-2.0.0.rc3 app/actors/hyrax/actors/apply_permission_template_actor.rb
hyrax-2.0.0.rc2 app/actors/hyrax/actors/apply_permission_template_actor.rb
hyrax-2.0.0.rc1 app/actors/hyrax/actors/apply_permission_template_actor.rb
hyrax-2.0.0.beta5 app/actors/hyrax/actors/apply_permission_template_actor.rb
hyrax-2.0.0.beta4 app/actors/hyrax/actors/apply_permission_template_actor.rb
hyrax-2.0.0.beta3 app/actors/hyrax/actors/apply_permission_template_actor.rb
hyrax-2.0.0.beta2 app/actors/hyrax/actors/apply_permission_template_actor.rb
hyrax-2.0.0.beta1 app/actors/hyrax/actors/apply_permission_template_actor.rb