Module: Hyrax::Ability::AdminSetAbility

Defined in:
app/models/concerns/hyrax/ability/admin_set_ability.rb

Instance Method Summary collapse

Instance Method Details

#admin_set_abilitiesObject

rubocop:disable Metrics/MethodLength, Metrics/AbcSize



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/models/concerns/hyrax/ability/admin_set_ability.rb', line 5

def admin_set_abilities # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
  if admin?
    can :manage, [AdminSet, Hyrax::AdministrativeSet]
    can :manage_any, AdminSet
    can :manage_any, Hyrax::AdministrativeSet
    can :create_any, AdminSet
    can :create_any, Hyrax::AdministrativeSet
    can :view_admin_show_any, AdminSet
    can :view_admin_show_any, Hyrax::AdministrativeSet
  else
    if Hyrax::Collections::PermissionsService.can_manage_any_admin_set?(ability: self)
      can :manage_any, AdminSet
      can :manage_any, Hyrax::AdministrativeSet
    end
    if Hyrax::CollectionTypes::PermissionsService.can_create_admin_set_collection_type?(ability: self)
      can :create, [AdminSet, Hyrax::AdministrativeSet]
      can :create_any, AdminSet
      can :create_any, Hyrax::AdministrativeSet
    end
    if Hyrax::Collections::PermissionsService.can_view_admin_show_for_any_admin_set?(ability: self)
      can :view_admin_show_any, AdminSet
      can :view_admin_show_any, Hyrax::AdministrativeSet
    end
    # [:edit, :update, :destroy] for AdminSet is controlled by Hydra::Ability #edit_permissions
    can [:edit, :update, :destroy], Hyrax::AdministrativeSet do |admin_set| # for test by solr_doc, see solr_document_ability.rb
      test_edit(admin_set.id)
    end

    can :deposit, AdminSet do |admin_set| # for test by solr_doc, see collection_ability.rb
      Hyrax::Collections::PermissionsService.can_deposit_in_collection?(ability: self, collection_id: admin_set.id)
    end
    can :deposit, Hyrax::AdministrativeSet do |admin_set| # for test by solr_doc, see collection_ability.rb
      Hyrax::Collections::PermissionsService.can_deposit_in_collection?(ability: self, collection_id: admin_set.id)
    end

    can :view_admin_show, AdminSet do |admin_set| # admin show page # for test by solr_doc, see collection_ability.rb
      Hyrax::Collections::PermissionsService.can_view_admin_show_for_collection?(ability: self, collection_id: admin_set.id)
    end
    can :view_admin_show, Hyrax::AdministrativeSet do |admin_set| # admin show page # for test by solr_doc, see collection_ability.rb
      Hyrax::Collections::PermissionsService.can_view_admin_show_for_collection?(ability: self, collection_id: admin_set.id)
    end

    # [:read] for AdminSet is controlled by Hydra::Ability #read_permissions
    can :read, Hyrax::AdministrativeSet do |admin_set| # admin show page # for test by solr_doc, see collection_ability.rb
      test_read(admin_set.id)
    end
  end

  # TODO: I'm not sure why this is checked with AdminSet abilities.  It was before the refactor and since I'm not sure what the connection is, I left it here.
  can :review, :submissions do
    can_review_submissions?
  end
end