2021-02-09 17:45:12 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module PermissionExtends
|
|
|
|
module ProjectPermissions
|
|
|
|
%w(
|
|
|
|
READ
|
2021-09-07 17:27:52 +08:00
|
|
|
READ_ARCHIVED
|
2021-02-09 17:45:12 +08:00
|
|
|
MANAGE
|
2021-09-07 17:27:52 +08:00
|
|
|
ACTIVITIES_READ
|
|
|
|
USERS_READ
|
|
|
|
USERS_MANAGE
|
|
|
|
COMMENTS_READ
|
|
|
|
COMMENTS_CREATE
|
|
|
|
COMMENTS_MANAGE
|
2021-10-04 21:43:50 +08:00
|
|
|
COMMENTS_MANAGE_OWN
|
2021-09-22 21:28:32 +08:00
|
|
|
TAGS_MANAGE
|
2021-09-07 17:27:52 +08:00
|
|
|
EXPERIMENTS_CREATE
|
2021-03-01 21:28:21 +08:00
|
|
|
).each { |permission| const_set(permission, "project_#{permission.underscore}") }
|
2021-02-09 17:45:12 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
module ExperimentPermissions
|
|
|
|
%w(
|
|
|
|
READ
|
2021-09-22 21:28:32 +08:00
|
|
|
READ_ARCHIVED
|
|
|
|
ACTIVITIES_READ
|
2021-02-09 17:45:12 +08:00
|
|
|
MANAGE
|
2021-09-22 21:28:32 +08:00
|
|
|
TASKS_MANAGE
|
|
|
|
USERS_READ
|
|
|
|
USERS_MANAGE
|
2021-09-30 17:32:11 +08:00
|
|
|
READ_ARCHIVED
|
|
|
|
READ_CANVAS
|
|
|
|
ACTIVITIES_READ
|
2021-03-01 21:28:21 +08:00
|
|
|
).each { |permission| const_set(permission, "experiment_#{permission.underscore}") }
|
2021-02-09 17:45:12 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
module MyModulePermissions
|
|
|
|
%w(
|
2021-02-18 16:54:53 +08:00
|
|
|
READ
|
2021-10-13 20:12:24 +08:00
|
|
|
ACTIVITIES_READ
|
2021-02-09 17:45:12 +08:00
|
|
|
MANAGE
|
2021-09-14 17:08:35 +08:00
|
|
|
STEPS_MANAGE
|
2021-09-22 17:28:32 +08:00
|
|
|
UPDATE_STATUS
|
|
|
|
COMMENTS_CREATE
|
2021-09-14 17:08:35 +08:00
|
|
|
COMMENTS_MANAGE
|
2021-09-16 20:12:51 +08:00
|
|
|
COMMENTS_MANAGE_OWN
|
2021-09-14 17:08:35 +08:00
|
|
|
RESULTS_MANAGE
|
|
|
|
RESULTS_DELETE_ARCHIVED
|
2021-09-24 19:11:41 +08:00
|
|
|
RESULTS_COMMENTS_MANAGE
|
|
|
|
RESULTS_COMMENTS_MANAGE_OWN
|
|
|
|
RESULTS_COMMENTS_CREATE
|
2021-09-22 17:28:32 +08:00
|
|
|
TAGS_MANAGE
|
2021-09-14 17:08:35 +08:00
|
|
|
PROTOCOL_MANAGE
|
|
|
|
COMPLETE
|
|
|
|
STEPS_COMPLETE
|
|
|
|
STEPS_UNCOMPLETE
|
2021-09-22 21:28:32 +08:00
|
|
|
STEPS_CHECKLIST_CHECK
|
|
|
|
STEPS_CHECKLIST_UNCHECK
|
2021-09-14 17:08:35 +08:00
|
|
|
STEPS_COMMENTS_CREATE
|
|
|
|
STEPS_COMMENTS_DELETE
|
|
|
|
STEPS_COMMENTS_DELETE_OWN
|
|
|
|
STEPS_COMMENTS_UPDATE
|
|
|
|
STEPS_COMMENT_UPDATE_OWN
|
|
|
|
REPOSITORY_ROWS_ASSIGN
|
2021-09-22 17:28:32 +08:00
|
|
|
REPOSITORY_ROWS_MANAGE
|
|
|
|
USERS_MANAGE
|
2021-03-01 21:28:21 +08:00
|
|
|
).each { |permission| const_set(permission, "task_#{permission.underscore}") }
|
2021-02-09 17:45:12 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
module RepositoryPermissions
|
|
|
|
%w(
|
|
|
|
READ
|
|
|
|
MANAGE
|
|
|
|
ARCHIVE
|
|
|
|
RESTORE
|
|
|
|
SHARE
|
|
|
|
CREATE_SNAPSHOT
|
|
|
|
DELETE_SNAPSHOT
|
|
|
|
CREATE_ROW
|
|
|
|
UPDATE_ROW
|
|
|
|
DELETE_ROW
|
|
|
|
CREATE_COLUMN
|
|
|
|
UPDATE_COLUMN
|
|
|
|
DELETE_COLUMN
|
2021-03-01 21:28:21 +08:00
|
|
|
).each { |permission| const_set(permission, "inventory_#{permission.underscore}") }
|
2021-02-09 17:45:12 +08:00
|
|
|
end
|
2021-09-30 17:32:11 +08:00
|
|
|
|
|
|
|
module PredefinedRoles
|
|
|
|
OWNER_PERMISSIONS = (
|
|
|
|
ProjectPermissions.constants.map { |const| ProjectPermissions.const_get(const) } +
|
|
|
|
ExperimentPermissions.constants.map { |const| ExperimentPermissions.const_get(const) } +
|
|
|
|
MyModulePermissions.constants.map { |const| MyModulePermissions.const_get(const) }
|
|
|
|
)
|
|
|
|
|
|
|
|
NORMAL_USER_PERMISSIONS = [
|
|
|
|
ProjectPermissions::READ,
|
|
|
|
ProjectPermissions::READ_ARCHIVED,
|
|
|
|
ProjectPermissions::ACTIVITIES_READ,
|
|
|
|
ProjectPermissions::USERS_READ,
|
|
|
|
ProjectPermissions::COMMENTS_READ,
|
|
|
|
ProjectPermissions::COMMENTS_CREATE,
|
2021-10-04 21:43:50 +08:00
|
|
|
ProjectPermissions::COMMENTS_MANAGE_OWN,
|
2021-09-30 17:32:11 +08:00
|
|
|
ProjectPermissions::EXPERIMENTS_CREATE,
|
|
|
|
ExperimentPermissions::READ,
|
2021-10-04 17:50:08 +08:00
|
|
|
ExperimentPermissions::READ_CANVAS,
|
2021-09-30 17:32:11 +08:00
|
|
|
ExperimentPermissions::MANAGE,
|
|
|
|
ExperimentPermissions::TASKS_MANAGE,
|
2021-10-22 19:05:31 +08:00
|
|
|
ExperimentPermissions::USERS_READ,
|
2021-09-30 17:32:11 +08:00
|
|
|
MyModulePermissions::READ,
|
2021-10-13 20:12:24 +08:00
|
|
|
MyModulePermissions::ACTIVITIES_READ,
|
2021-09-30 17:32:11 +08:00
|
|
|
MyModulePermissions::MANAGE,
|
|
|
|
MyModulePermissions::RESULTS_MANAGE,
|
|
|
|
MyModulePermissions::PROTOCOL_MANAGE,
|
|
|
|
MyModulePermissions::STEPS_MANAGE,
|
|
|
|
MyModulePermissions::TAGS_MANAGE,
|
|
|
|
MyModulePermissions::COMMENTS_CREATE,
|
|
|
|
MyModulePermissions::COMMENTS_MANAGE,
|
|
|
|
MyModulePermissions::COMMENTS_MANAGE_OWN,
|
|
|
|
MyModulePermissions::COMPLETE,
|
|
|
|
MyModulePermissions::UPDATE_STATUS,
|
|
|
|
MyModulePermissions::STEPS_COMPLETE,
|
|
|
|
MyModulePermissions::STEPS_UNCOMPLETE,
|
|
|
|
MyModulePermissions::STEPS_CHECKLIST_CHECK,
|
|
|
|
MyModulePermissions::STEPS_CHECKLIST_UNCHECK,
|
|
|
|
MyModulePermissions::STEPS_COMMENTS_CREATE,
|
|
|
|
MyModulePermissions::STEPS_COMMENTS_DELETE_OWN,
|
|
|
|
MyModulePermissions::STEPS_COMMENT_UPDATE_OWN,
|
|
|
|
MyModulePermissions::REPOSITORY_ROWS_ASSIGN,
|
|
|
|
MyModulePermissions::REPOSITORY_ROWS_MANAGE
|
|
|
|
]
|
|
|
|
|
|
|
|
TECHNICIAN_PERMISSIONS = [
|
|
|
|
ProjectPermissions::READ,
|
|
|
|
ProjectPermissions::READ_ARCHIVED,
|
|
|
|
ProjectPermissions::ACTIVITIES_READ,
|
|
|
|
ProjectPermissions::USERS_READ,
|
|
|
|
ProjectPermissions::COMMENTS_READ,
|
|
|
|
ProjectPermissions::COMMENTS_CREATE,
|
2021-10-04 21:43:50 +08:00
|
|
|
ProjectPermissions::COMMENTS_MANAGE_OWN,
|
2021-09-30 17:32:11 +08:00
|
|
|
ExperimentPermissions::READ,
|
2021-10-04 17:50:08 +08:00
|
|
|
ExperimentPermissions::READ_CANVAS,
|
2021-09-30 17:32:11 +08:00
|
|
|
ExperimentPermissions::READ_ARCHIVED,
|
|
|
|
ExperimentPermissions::ACTIVITIES_READ,
|
|
|
|
ExperimentPermissions::USERS_READ,
|
|
|
|
MyModulePermissions::READ,
|
2021-10-13 20:12:24 +08:00
|
|
|
MyModulePermissions::ACTIVITIES_READ,
|
2021-09-30 17:32:11 +08:00
|
|
|
MyModulePermissions::COMMENTS_CREATE,
|
|
|
|
MyModulePermissions::COMMENTS_MANAGE_OWN,
|
|
|
|
MyModulePermissions::COMPLETE,
|
|
|
|
MyModulePermissions::UPDATE_STATUS,
|
|
|
|
MyModulePermissions::STEPS_COMPLETE,
|
|
|
|
MyModulePermissions::STEPS_UNCOMPLETE,
|
|
|
|
MyModulePermissions::STEPS_CHECKLIST_CHECK,
|
|
|
|
MyModulePermissions::STEPS_CHECKLIST_UNCHECK,
|
|
|
|
MyModulePermissions::STEPS_COMMENTS_CREATE,
|
|
|
|
MyModulePermissions::STEPS_COMMENTS_DELETE_OWN,
|
|
|
|
MyModulePermissions::STEPS_COMMENT_UPDATE_OWN,
|
|
|
|
MyModulePermissions::REPOSITORY_ROWS_ASSIGN,
|
|
|
|
MyModulePermissions::REPOSITORY_ROWS_MANAGE
|
|
|
|
]
|
|
|
|
|
|
|
|
VIEWER_PERMISSIONS = [
|
|
|
|
ProjectPermissions::READ,
|
|
|
|
ProjectPermissions::READ_ARCHIVED,
|
|
|
|
ProjectPermissions::ACTIVITIES_READ,
|
|
|
|
ProjectPermissions::USERS_READ,
|
|
|
|
ProjectPermissions::COMMENTS_READ,
|
|
|
|
ExperimentPermissions::READ,
|
2021-10-04 17:50:08 +08:00
|
|
|
ExperimentPermissions::READ_CANVAS,
|
2021-09-30 17:32:11 +08:00
|
|
|
ExperimentPermissions::READ_ARCHIVED,
|
|
|
|
ExperimentPermissions::ACTIVITIES_READ,
|
|
|
|
ExperimentPermissions::USERS_READ,
|
2021-10-13 20:12:24 +08:00
|
|
|
MyModulePermissions::READ,
|
|
|
|
MyModulePermissions::ACTIVITIES_READ
|
2021-09-30 17:32:11 +08:00
|
|
|
]
|
|
|
|
end
|
2021-02-09 17:45:12 +08:00
|
|
|
end
|