Module: CurationConcerns::Ability

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/curation_concerns/ability.rb

Instance Method Summary collapse

Instance Method Details

#add_to_collectionObject



47
48
49
50
# File 'app/models/concerns/curation_concerns/ability.rb', line 47

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

#admin?Boolean

Override this method in your ability model if you use a different group or other logic to designate an administrator.

Returns:

  • (Boolean)


43
44
45
# File 'app/models/concerns/curation_concerns/ability.rb', line 43

def admin?
  user_groups.include? 'admin'
end

#admin_permissionsObject



31
32
33
34
35
36
37
38
39
# File 'app/models/concerns/curation_concerns/ability.rb', line 31

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

#curation_concerns_permissionsObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/concerns/curation_concerns/ability.rb', line 10

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
  alias_action :file_manager, to: :update

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

#everyone_can_create_curation_concernsObject

Add this to your ability_logic if you want all logged in users to be able to submit content



58
59
60
61
# File 'app/models/concerns/curation_concerns/ability.rb', line 58

def everyone_can_create_curation_concerns
  return unless registered_user?
  can :create, curation_concerns_models
end

#operation_abilitiesObject



27
28
29
# File 'app/models/concerns/curation_concerns/ability.rb', line 27

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

#registered_user?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'app/models/concerns/curation_concerns/ability.rb', line 52

def registered_user?
  user_groups.include? 'registered'
end