Sha256: 4e19498bef4458fea852d55fca144e559ef6db6c9b4e21104c72a53559172e31

Contents?: true

Size: 909 Bytes

Versions: 3

Compression:

Stored size: 909 Bytes

Contents

module Sufia
  class ApplyPermissionTemplateActor < CurationConcerns::Actors::AbstractActor
    def create(attributes)
      add_edit_users(attributes)
      next_actor.create(attributes)
    end

    protected

      def add_edit_users(attributes)
        return unless attributes[:admin_set_id].present?
        template = Sufia::PermissionTemplate.find_by!(admin_set_id: attributes[:admin_set_id])
        curation_concern.edit_users = template.access_grants.where(agent_type: 'user', access: 'manage').pluck(:agent_id)
        curation_concern.edit_groups = template.access_grants.where(agent_type: 'group', access: 'manage').pluck(:agent_id)
        curation_concern.read_users = template.access_grants.where(agent_type: 'user', access: 'view').pluck(:agent_id)
        curation_concern.read_groups = template.access_grants.where(agent_type: 'group', access: 'view').pluck(:agent_id)
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sufia-7.3.0.rc3 app/actors/sufia/apply_permission_template_actor.rb
sufia-7.3.0.rc2 app/actors/sufia/apply_permission_template_actor.rb
sufia-7.3.0.rc1 app/actors/sufia/apply_permission_template_actor.rb