mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 13:13:22 +08:00
Merge pull request #1337 from jbargu/jg_bug_sci_2805
Add can_export_project? permission to allow archived projects to be exported [SCI-2805]
This commit is contained in:
commit
7d2f2c3b5f
2 changed files with 19 additions and 5 deletions
|
@ -314,7 +314,7 @@ class TeamsController < ApplicationController
|
|||
if export_projects_params[:project_ids]
|
||||
projects = Project.where(id: export_projects_params[:project_ids])
|
||||
projects.each do |project|
|
||||
render_403 unless can_read_project?(current_user, project)
|
||||
render_403 unless can_export_project?(current_user, project)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,13 +12,27 @@ Canaid::Permissions.register_for(Project) do
|
|||
end
|
||||
end
|
||||
|
||||
%i(read_project
|
||||
export_project)
|
||||
.each do |perm|
|
||||
can perm do |user, project|
|
||||
user.is_member_of_project?(project) ||
|
||||
user.is_admin_of_team?(project.team) ||
|
||||
(project.visible? && user.is_member_of_team?(project.team))
|
||||
end
|
||||
end
|
||||
# project: read, read activities, read comments, read users, read archive,
|
||||
# read notifications
|
||||
# reports: read
|
||||
can :read_project do |user, project|
|
||||
user.is_member_of_project?(project) ||
|
||||
user.is_admin_of_team?(project.team) ||
|
||||
(project.visible? && user.is_member_of_team?(project.team))
|
||||
can :read_project do |_, _|
|
||||
# Already checked by the wrapper
|
||||
true
|
||||
end
|
||||
|
||||
# team: export projects
|
||||
can :export_project do |_, _|
|
||||
# Already checked by the wrapper
|
||||
true
|
||||
end
|
||||
|
||||
# project: update/delete, assign/reassign/unassign users
|
||||
|
|
Loading…
Reference in a new issue