Sha256: 9cca39fb11e5677efb6554be7b522514e0bfdf6b01b0f596882179a138c7a34b

Contents?: true

Size: 1.74 KB

Versions: 6

Compression:

Stored size: 1.74 KB

Contents

module CurationConcerns
  module Ability
    extend ActiveSupport::Concern
    included do
      self.ability_logic += [:curation_concerns_permissions,
                             :operation_abilities,
                             :add_to_collection]
    end

    def curation_concerns_permissions
      unless current_user.new_record?
        can :create, CurationConcerns::ClassifyConcern
      end

      # user can version if they can edit
      alias_action :versions, to: :update

      if admin?
        admin_permissions
      else
        cannot :index, Hydra::AccessControls::Embargo
        cannot :index, Hydra::AccessControls::Lease
      end
    end

    def operation_abilities
      can :read, Operation, user_id: current_user.id
    end

    def admin_permissions
      can :read, :admin_dashboard
      alias_action :edit, to: :update
      alias_action :show, to: :read
      alias_action :discover, to: :read

      can :manage, curation_concerns_models
      can :manage, Sipity::WorkflowResponsibility
    end

    # Override this method in your ability model if you use a different group
    # or other logic to designate an administrator.
    def admin?
      user_groups.include? 'admin'
    end

    def add_to_collection
      return if current_user.new_record?
      can :collect, :all
    end

    def registered_user?
      user_groups.include? 'registered'
    end

    # Add this to your ability_logic if you want all logged in users to be able
    # to submit content
    def everyone_can_create_curation_concerns
      return unless registered_user?
      can :create, curation_concerns_models
    end

    private

      def curation_concerns_models
        [::FileSet, ::Collection] + CurationConcerns.config.curation_concerns
      end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
curation_concerns-1.7.3 app/models/concerns/curation_concerns/ability.rb
curation_concerns-1.7.2 app/models/concerns/curation_concerns/ability.rb
curation_concerns-2.0.0.rc1 app/models/concerns/curation_concerns/ability.rb
curation_concerns-1.7.1 app/models/concerns/curation_concerns/ability.rb
curation_concerns-1.7.0 app/models/concerns/curation_concerns/ability.rb
curation_concerns-1.7.0.beta1 app/models/concerns/curation_concerns/ability.rb