mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-05 22:44:22 +08:00
Add permissions for comments to permission_helper.rb
This commit is contained in:
parent
5569a1e6d2
commit
319bcc7850
1 changed files with 81 additions and 0 deletions
|
@ -302,6 +302,19 @@ module PermissionHelper
|
||||||
is_technician_or_higher_of_project(project)
|
is_technician_or_higher_of_project(project)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def can_edit_project_comment(comment)
|
||||||
|
comment.project_comment.present? &&
|
||||||
|
(
|
||||||
|
comment.user == current_user ||
|
||||||
|
is_owner_of_project(comment.project_comment.project)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def can_delete_project_comment(comment)
|
||||||
|
comment.user == current_user ||
|
||||||
|
is_owner_of_project(project)
|
||||||
|
end
|
||||||
|
|
||||||
def can_restore_archived_modules(project)
|
def can_restore_archived_modules(project)
|
||||||
is_user_or_higher_of_project(project)
|
is_user_or_higher_of_project(project)
|
||||||
end
|
end
|
||||||
|
@ -475,6 +488,26 @@ module PermissionHelper
|
||||||
is_technician_or_higher_of_project(my_module.experiment.project)
|
is_technician_or_higher_of_project(my_module.experiment.project)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def can_edit_module_comment(comment)
|
||||||
|
comment.my_module_comment.present? &&
|
||||||
|
(
|
||||||
|
comment.user == current_user ||
|
||||||
|
is_owner_of_project(
|
||||||
|
comment.my_module_comment.my_module.experiment.project
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def can_delete_module_comment(comment)
|
||||||
|
comment.my_module_comment.present? &&
|
||||||
|
(
|
||||||
|
comment.user == current_user ||
|
||||||
|
is_owner_of_project(
|
||||||
|
comment.my_module_comment.my_module.experiment.project
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def can_view_module_samples(my_module)
|
def can_view_module_samples(my_module)
|
||||||
can_view_module(my_module) and
|
can_view_module(my_module) and
|
||||||
can_view_samples(my_module.experiment.project.organization)
|
can_view_samples(my_module.experiment.project.organization)
|
||||||
|
@ -502,6 +535,26 @@ module PermissionHelper
|
||||||
is_technician_or_higher_of_project(my_module.experiment.project)
|
is_technician_or_higher_of_project(my_module.experiment.project)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def can_edit_result_comment_in_module(comment)
|
||||||
|
comment.result_comment.present? &&
|
||||||
|
(
|
||||||
|
comment.user == current_user ||
|
||||||
|
is_owner_of_project(
|
||||||
|
comment.result_comment.result.my_module.experiment.project
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def can_delete_result_comment_in_module(comment)
|
||||||
|
comment.result_comment.present? &&
|
||||||
|
(
|
||||||
|
comment.user == current_user ||
|
||||||
|
is_owner_of_project(
|
||||||
|
comment.result_comment.result.my_module.experiment.project
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
# ---- RESULT TEXT PERMISSIONS ----
|
# ---- RESULT TEXT PERMISSIONS ----
|
||||||
|
|
||||||
def can_create_result_text_in_module(my_module)
|
def can_create_result_text_in_module(my_module)
|
||||||
|
@ -874,6 +927,34 @@ module PermissionHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def can_edit_step_comment_in_protocol(comment)
|
||||||
|
if protocol.in_module?
|
||||||
|
comment.step_comment.present? &&
|
||||||
|
(
|
||||||
|
comment.user == current_user ||
|
||||||
|
is_owner_of_project(
|
||||||
|
comment.step_comment.step.protocol.my_module.experiment.project
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def can_delete_step_comment_in_protocol(comment)
|
||||||
|
if protocol.in_module?
|
||||||
|
comment.step_comment.present? &&
|
||||||
|
(
|
||||||
|
comment.user == current_user ||
|
||||||
|
is_owner_of_project(
|
||||||
|
comment.step_comment.step.protocol.my_module.experiment.project
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def can_view_or_download_step_assets(protocol)
|
def can_view_or_download_step_assets(protocol)
|
||||||
if protocol.in_module?
|
if protocol.in_module?
|
||||||
my_module = protocol.my_module
|
my_module = protocol.my_module
|
||||||
|
|
Loading…
Reference in a new issue