-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1774 from samvera/collections-1669-abilities
Solidify abilities using permission services
- Loading branch information
Showing
26 changed files
with
1,642 additions
and
432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module Hyrax | ||
module Ability | ||
module AdminSetAbility | ||
def admin_set_abilities # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity | ||
can :manage, AdminSet if admin? | ||
can :manage_any, AdminSet if admin? || | ||
Hyrax::Collections::PermissionsService.can_manage_any_admin_set?(ability: self) | ||
can :create_any, AdminSet if admin? || | ||
Hyrax::CollectionTypes::PermissionsService.can_create_admin_set_collection_type?(ability: self) | ||
can :view_admin_show_any, AdminSet if admin? || | ||
Hyrax::Collections::PermissionsService.can_view_admin_show_for_any_admin_set?(ability: self) | ||
can [:edit, :update, :destroy], AdminSet do |admin_set| | ||
test_edit(admin_set.id) | ||
end | ||
can :deposit, AdminSet do |admin_set| | ||
Hyrax::Collections::PermissionsService.can_deposit_in_collection?(ability: self, collection: admin_set) | ||
end | ||
can :view_admin_show, AdminSet do |admin_set| # admin show page | ||
Hyrax::Collections::PermissionsService.can_view_admin_show_for_collection?(ability: self, collection: admin_set) | ||
end | ||
can :read, AdminSet do |admin_set| # public show page | ||
test_read(admin_set.id) | ||
end | ||
|
||
can :review, :submissions do | ||
can_review_submissions? | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Hyrax | ||
module Ability | ||
module CollectionAbility | ||
def collection_abilities # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity | ||
can :manage, Collection if admin? | ||
can :manage_any, Collection if admin? || | ||
Hyrax::Collections::PermissionsService.can_manage_any_collection?(ability: self) | ||
can :create_any, Collection if admin? || | ||
Hyrax::CollectionTypes::PermissionsService.can_create_any_collection_type?(ability: self) | ||
can :view_admin_show_any, Collection if admin? || | ||
Hyrax::Collections::PermissionsService.can_view_admin_show_for_any_collection?(ability: self) | ||
can [:edit, :update, :destroy], Collection do |collection| | ||
test_edit(collection.id) | ||
end | ||
can :deposit, Collection do |collection| | ||
Hyrax::Collections::PermissionsService.can_deposit_in_collection?(user: current_user, collection: collection) | ||
end | ||
can :view_admin_show, Collection do |collection| # admin show page | ||
Hyrax::Collections::PermissionsService.can_view_admin_show_for_collection?(user: current_user, collection: collection) | ||
end | ||
can :read, Collection do |collection| # public show page | ||
test_read(collection.id) | ||
end | ||
end | ||
end | ||
end | ||
end |
12 changes: 12 additions & 0 deletions
12
app/models/concerns/hyrax/ability/collection_type_ability.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Hyrax | ||
module Ability | ||
module CollectionTypeAbility | ||
def collection_type_abilities | ||
can :manage, CollectionType if admin? | ||
can :create_collection_of_type, CollectionType do |collection_type| | ||
Hyrax::CollectionTypes::PermissionsService.can_create_collection_of_type?(user: current_user, collection_type: collection_type) | ||
end | ||
end | ||
end | ||
end | ||
end |
16 changes: 16 additions & 0 deletions
16
app/models/concerns/hyrax/ability/permission_template_ability.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module Hyrax | ||
module Ability | ||
module PermissionTemplateAbility | ||
def permission_template_abilities | ||
can :manage, [Hyrax::PermissionTemplate, Hyrax::PermissionTemplateAccess] if admin? | ||
|
||
can [:create, :edit, :update, :destroy], Hyrax::PermissionTemplate do |template| | ||
test_edit(template.source_id) | ||
end | ||
can [:create, :edit, :update, :destroy], Hyrax::PermissionTemplateAccess do |access| | ||
test_edit(access.permission_template.source_id) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.