Skip to content

Commit

Permalink
Fixes needed to save resources
Browse files Browse the repository at this point in the history
- Added Hyrax::Works::ValkyrieMigration to work resources
- Added Hyku::WorksControllerBehavior to resource controllers
- WIP: temp removal of permission_manager_decorator - will be replaced once fixed.
  • Loading branch information
LaRita Robinson committed Jan 15, 2024
1 parent a23d474 commit bf27e9f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 23 deletions.
1 change: 1 addition & 0 deletions app/controllers/concerns/hyku/works_controller_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module WorksControllerBehavior
included do
# add around action to load theme show page views
around_action :inject_show_theme_views, except: :delete
self.show_presenter = Hyku::WorkShowPresenter
end

def json_manifest
Expand Down
1 change: 1 addition & 0 deletions app/controllers/hyrax/generic_work_resources_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Hyrax
class GenericWorkResourcesController < ApplicationController
# Adds Hyrax behaviors to the controller.
include Hyrax::WorksControllerBehavior
include Hyku::WorksControllerBehavior
include Hyrax::BreadcrumbsForWorks
self.curation_concern_type = ::GenericWorkResource

Expand Down
1 change: 1 addition & 0 deletions app/controllers/hyrax/image_resources_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Hyrax
class ImageResourcesController < ApplicationController
# Adds Hyrax behaviors to the controller.
include Hyrax::WorksControllerBehavior
include Hyku::WorksControllerBehavior
include Hyrax::BreadcrumbsForWorks
self.curation_concern_type = ::ImageResource

Expand Down
1 change: 1 addition & 0 deletions app/models/generic_work_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ class GenericWorkResource < Hyrax::Work
include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:generic_work_resource)
include Hyrax::ArResource
include Hyrax::Works::ValkyrieMigration
end
1 change: 1 addition & 0 deletions app/models/image_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ class ImageResource < Hyrax::Work
include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:image_resource)
include Hyrax::ArResource
include Hyrax::Works::ValkyrieMigration
end
47 changes: 24 additions & 23 deletions app/services/hyrax/permission_manager_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,32 @@ module Hyrax
module PermissionManagerDecorator
private

def update_groups_for(mode:, groups:)
groups = groups.map(&:to_s)
# def update_groups_for(mode:, groups:)
# groups = groups.map(&:to_s)
# debugger
# acl.permissions.each do |permission|
# next unless permission.mode.to_sym == mode
# next unless permission.agent.starts_with?(Hyrax::Group.name_prefix)

acl.permissions.each do |permission|
next unless permission.mode.to_sym == mode
next unless permission.agent.starts_with?(Hyrax::Group.name_prefix)
# group_name = permission.agent.gsub(Hyrax::Group.name_prefix, '')
# next if groups.include?(group_name)
# debugger
# # OVERRIDE:
# # - Replace Group#new with Group#find_by(:name)
# # - Add fallback on Role, which has the same agent_type as Group
# group_or_role = Group.find_by(name: group_name) || Role.find_by(name: group_name)
# acl.revoke(mode).from(group_or_role)
# end

group_name = permission.agent.gsub(Hyrax::Group.name_prefix, '')
next if groups.include?(group_name)

# OVERRIDE:
# - Replace Group#new with Group#find_by(:name)
# - Add fallback on Role, which has the same agent_type as Group
group_or_role = Group.find_by(name: group_name) || Role.find_by(name: group_name)
acl.revoke(mode).from(group_or_role)
end

groups.each do |g|
# OVERRIDE:
# - Replace Group#new with Group#find_by(:name)
# - Add fallback on Role, which has the same agent_type as Group
group_or_role = Group.find_by(name: g) || Role.find_by(name: g)
acl.grant(mode).to(group_or_role)
end
end
# groups.each do |g|
# debugger
# # OVERRIDE:
# # - Replace Group#new with Group#find_by(:name)
# # - Add fallback on Role, which has the same agent_type as Group
# group_or_role = Group.find_by(name: g) || Role.find_by(name: g)
# acl.grant(mode).to(group_or_role)
# end
# end
end
end

Expand Down

0 comments on commit bf27e9f

Please sign in to comment.