mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 17:51:13 +08:00
Refactor read_project/export_project permissions
This commit is contained in:
parent
bd5a2a43fd
commit
3903b4a6f2
1 changed files with 18 additions and 11 deletions
|
@ -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
|
||||
|
@ -38,13 +52,6 @@ Canaid::Permissions.register_for(Project) do
|
|||
user.is_owner_of_project?(project) && project.archived?
|
||||
end
|
||||
|
||||
# team: export projects
|
||||
can :export_project do |user, project|
|
||||
user.is_technician_or_higher_of_project?(project) ||
|
||||
user.viewer?(project) ||
|
||||
user.is_admin_of_team?(project.team) ||
|
||||
(project.visible? && user.is_member_of_team?(project.team))
|
||||
end
|
||||
|
||||
# experiment: create
|
||||
can :create_experiments do |user, project|
|
||||
|
|
Loading…
Reference in a new issue