Skip to content
Snippets Groups Projects
Commit bc8509f6 authored by Kapil Patel's avatar Kapil Patel
Browse files

Fix deposit permission

parent 905fc513
No related tags found
1 merge request!180Fixed deposit permission
Pipeline #7501 failed
......@@ -19,7 +19,7 @@ module Hyrax
def authorize_collection_access
group_id = params[:add_works_to_collection]
if current_user.admin? || current_user.crc_manager_for?(group_id) || current_user.group_manager_for?(group_id) || current_user.group_member_for?(group_id)
if current_user.admin? || current_user.crc_manager_for?(group_id) || current_user.group_manager_for?(group_id) || current_user.group_member_for?(group_id) || current_user.crc_member_for?(group_id)
return true
end
......
......@@ -28,7 +28,7 @@ module HyraxHelper
end
def can_create_work_in_group?(group_id)
current_user.admin? || current_user.crc_manager_for?(group_id) || current_user.group_manager_for?(group_id) || current_user.group_member_for?(group_id)
current_user.admin? || current_user.crc_manager_for?(group_id) || current_user.group_manager_for?(group_id) || current_user.group_member_for?(group_id) || current_user.crc_member_for?(group_id)
end
def can_manage_managers_for_group?(presenter)
......
......@@ -41,6 +41,14 @@ class User < ApplicationRecord
roles.where(name: "#{group.collection_type.title.parameterize(separator: '_')}_manager").any?
end
def crc_member_for?(group_id)
group = Collection.find(group_id) rescue nil
return false unless group
roles.where(name: "#{group.collection_type.title.parameterize(separator: '_')}_member").any?
end
def group_manager_for?(group_id)
group = Collection.find(group_id) rescue nil
......
......@@ -27,6 +27,7 @@ module Hyrax
return if depositor?(current_work: current_work)
return if group_manager?(current_work: current_work)
return if crc_manager?(current_work: current_work)
return if crc_member?(current_work: current_work)
return if publication_manager?(current_work: current_work)
return if proxy_depositor?(current_work: current_work)
super
......@@ -59,6 +60,11 @@ module Hyrax
return true if current_user.crc_manager_for?(current_work.member_of_collection_ids.first)
end
def crc_member?(current_work:)
current_user = current_ability.current_user
return true if current_user.crc_member_for?(current_work.member_of_collection_ids.first)
end
def publication_manager?(current_work:)
current_user = current_ability.current_user
return true if current_user.publication_manager?
......
......@@ -96,7 +96,7 @@ module Hyrax
%w[manager member].each do |role_type|
if role_type == 'member'
agents << { agent_type: 'group',
agent_id: "#{collection_type.title.parameterize(separator: '_')}_#{collection.id}_#{role_type}", access: Hyrax::PermissionTemplateAccess::DEPOSIT, is_system_generated: true }
agent_id: "#{collection_type.title.parameterize(separator: '_')}_#{collection.id}_#{role_type}", access: Hyrax::PermissionTemplateAccess::VIEW, is_system_generated: true }
end
role = Role.find_or_initialize_by(name: "#{collection_type.title.parameterize(separator: '_')}_#{collection.id}_#{role_type}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment