mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 02:04:33 +08:00
Merge pull request #4737 from okriuchykhin/ok_SCI_7643
Add missing permissions for inventories and protocols [SCI-7643]
This commit is contained in:
commit
2ea5000ea5
3 changed files with 47 additions and 2 deletions
|
@ -18,6 +18,7 @@ module PermissionExtends
|
|||
module ProtocolPermissions
|
||||
%w(
|
||||
READ
|
||||
READ_ARCHIVED
|
||||
MANAGE
|
||||
USERS_MANAGE
|
||||
).each { |permission| const_set(permission, "protocol_#{permission.underscore}") }
|
||||
|
@ -137,6 +138,7 @@ module PermissionExtends
|
|||
TeamPermissions::LABEL_TEMPLATES_READ,
|
||||
TeamPermissions::LABEL_TEMPLATES_MANAGE,
|
||||
ProtocolPermissions::READ,
|
||||
ProtocolPermissions::READ_ARCHIVED,
|
||||
ProtocolPermissions::MANAGE,
|
||||
ReportPermissions::READ,
|
||||
ReportPermissions::MANAGE,
|
||||
|
@ -228,6 +230,7 @@ module PermissionExtends
|
|||
VIEWER_PERMISSIONS = [
|
||||
TeamPermissions::LABEL_TEMPLATES_READ,
|
||||
ProtocolPermissions::READ,
|
||||
ProtocolPermissions::READ_ARCHIVED,
|
||||
ReportPermissions::READ,
|
||||
ProjectPermissions::READ,
|
||||
ProjectPermissions::READ_ARCHIVED,
|
||||
|
@ -242,7 +245,9 @@ module PermissionExtends
|
|||
MyModulePermissions::READ,
|
||||
MyModulePermissions::USERS_READ,
|
||||
MyModulePermissions::READ_ARCHIVED,
|
||||
MyModulePermissions::ACTIVITIES_READ
|
||||
MyModulePermissions::ACTIVITIES_READ,
|
||||
RepositoryPermissions::READ,
|
||||
RepositoryPermissions::READ_ARCHIVED
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddMissingRepositoryAndProtocolPermissions < ActiveRecord::Migration[6.1]
|
||||
OWNER_PERMISSIONS = [ProtocolPermissions::READ_ARCHIVED].freeze
|
||||
NORMAL_USER_PERMISSIONS = [ProtocolPermissions::READ_ARCHIVED].freeze
|
||||
VIEWER_PERMISSIONS = [ProtocolPermissions::READ_ARCHIVED,
|
||||
RepositoryPermissions::READ,
|
||||
RepositoryPermissions::READ_ARCHIVED].freeze
|
||||
|
||||
def change
|
||||
reversible do |dir|
|
||||
dir.up do
|
||||
owner_role = UserRole.find_predefined_owner_role
|
||||
normal_user_role = UserRole.find_predefined_normal_user_role
|
||||
viewer_role = UserRole.find_predefined_viewer_role
|
||||
|
||||
owner_role.permissions = owner_role.permissions | OWNER_PERMISSIONS
|
||||
owner_role.save(validate: false)
|
||||
normal_user_role.permissions = normal_user_role.permissions | NORMAL_USER_PERMISSIONS
|
||||
normal_user_role.save(validate: false)
|
||||
viewer_role.permissions = viewer_role.permissions | VIEWER_PERMISSIONS
|
||||
viewer_role.save(validate: false)
|
||||
end
|
||||
|
||||
dir.down do
|
||||
owner_role = UserRole.find_predefined_owner_role
|
||||
normal_user_role = UserRole.find_predefined_normal_user_role
|
||||
viewer_role = UserRole.find_predefined_viewer_role
|
||||
|
||||
owner_role.permissions = owner_role.permissions - OWNER_PERMISSIONS
|
||||
owner_role.save(validate: false)
|
||||
normal_user_role.permissions = normal_user_role.permissions - NORMAL_USER_PERMISSIONS
|
||||
normal_user_role.save(validate: false)
|
||||
viewer_role.permissions = viewer_role.permissions - VIEWER_PERMISSIONS
|
||||
viewer_role.save(validate: false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -8594,6 +8594,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
|||
('20220818094636'),
|
||||
('20220914124900'),
|
||||
('20221007113010'),
|
||||
('20221028085051');
|
||||
('20221028085051'),
|
||||
('20221222123021');
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue