Sha256: d49b02cebad6e8a3fa47f942924d0e7304237322842a07e96d39aea89b9845e4

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module CurationConcerns
  module Ability
    extend ActiveSupport::Concern
    included do
      self.ability_logic += [:curation_concerns_permissions]
    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

      can :collect, :all
    end

    def admin_permissions
      can [:create, :discover, :show, :read, :edit, :update, :destroy], :all
    end

    def admin?
      user_groups.include? 'admin'
    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 if current_user.new_record?
      can :create, [::FileSet, ::Collection]
      can :create, [CurationConcerns.config.curation_concerns]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
curation_concerns-models-0.2.0 app/models/concerns/curation_concerns/ability.rb