2017-11-27 18:24:41 +08:00
|
|
|
Canaid::Permissions.register_for(Team) do
|
2017-12-13 21:43:11 +08:00
|
|
|
# view projects, view protocols
|
|
|
|
# leave team, view team users (ATWHO)
|
2017-12-12 21:56:07 +08:00
|
|
|
# view samples, export samples
|
|
|
|
# view repositories, view repository, export repository rows
|
2017-11-27 18:24:41 +08:00
|
|
|
can :read_team do |user, team|
|
|
|
|
user.is_member_of_team?(team)
|
|
|
|
end
|
2017-11-28 22:41:52 +08:00
|
|
|
|
2017-12-04 18:12:35 +08:00
|
|
|
# edit team name, edit team description
|
|
|
|
can :update_team do |user, team|
|
|
|
|
user.is_admin_of_team?(team)
|
|
|
|
end
|
|
|
|
|
2017-12-13 21:36:46 +08:00
|
|
|
# invite user to team, change user's role, remove user from team
|
2018-01-05 22:15:50 +08:00
|
|
|
can :manage_team_users do |user, team|
|
2017-11-28 22:41:52 +08:00
|
|
|
user.is_admin_of_team?(team)
|
|
|
|
end
|
2017-12-04 20:07:23 +08:00
|
|
|
|
2017-12-08 00:08:41 +08:00
|
|
|
# create project
|
2018-01-05 22:15:50 +08:00
|
|
|
can :create_projects do |user, team|
|
2017-12-08 00:08:41 +08:00
|
|
|
user.is_normal_user_or_admin_of_team?(team)
|
|
|
|
end
|
|
|
|
|
2017-12-04 20:07:23 +08:00
|
|
|
# create protocol in repository, import protocol to repository
|
2018-01-05 22:15:50 +08:00
|
|
|
can :create_protocols_in_repository do |user, team|
|
2017-12-04 20:07:23 +08:00
|
|
|
user.is_normal_user_or_admin_of_team?(team)
|
|
|
|
end
|
2017-12-04 23:45:23 +08:00
|
|
|
|
2017-12-20 23:05:05 +08:00
|
|
|
# create, import, edit, delete samples
|
|
|
|
can :manage_samples do |user, team|
|
2017-12-04 23:45:23 +08:00
|
|
|
user.is_normal_user_or_admin_of_team?(team)
|
|
|
|
end
|
2017-12-07 23:40:27 +08:00
|
|
|
|
2018-01-03 23:37:02 +08:00
|
|
|
# create custom field
|
|
|
|
# create, update, delete sample type or sample group
|
2018-01-05 22:15:50 +08:00
|
|
|
can :manage_sample_columns do |user, team|
|
2017-12-07 23:40:27 +08:00
|
|
|
user.is_normal_user_or_admin_of_team?(team)
|
|
|
|
end
|
2017-12-12 21:30:28 +08:00
|
|
|
|
2018-01-05 18:17:01 +08:00
|
|
|
# create, copy repository
|
2018-01-05 22:15:50 +08:00
|
|
|
can :create_repositories do |user, team|
|
2017-12-13 18:09:25 +08:00
|
|
|
user.is_admin_of_team?(team)
|
|
|
|
end
|
|
|
|
|
2018-01-04 18:53:58 +08:00
|
|
|
# create, import, edit, delete repository records
|
|
|
|
can :manage_repository_rows do |user, team|
|
2017-12-12 21:30:28 +08:00
|
|
|
user.is_normal_user_or_admin_of_team?(team)
|
|
|
|
end
|
2017-12-12 22:35:43 +08:00
|
|
|
|
2018-01-05 17:43:59 +08:00
|
|
|
# create repository column
|
2018-01-05 22:15:50 +08:00
|
|
|
can :create_repository_columns do |user, team|
|
2017-12-12 22:35:43 +08:00
|
|
|
user.is_normal_user_or_admin_of_team?(team)
|
|
|
|
end
|
2017-11-28 22:41:52 +08:00
|
|
|
end
|
|
|
|
|
2017-12-06 02:51:44 +08:00
|
|
|
Canaid::Permissions.register_for(Protocol) do
|
|
|
|
# view protocol in repository, export protocol from repository
|
|
|
|
# view step in protocol in repository, view or dowload step asset
|
|
|
|
can :read_protocol_in_repository do |user, protocol|
|
|
|
|
user.is_member_of_team?(protocol.team) &&
|
|
|
|
(protocol.in_repository_public? ||
|
|
|
|
protocol.in_repository_private? && user == protocol.added_by)
|
|
|
|
end
|
2017-12-07 00:23:08 +08:00
|
|
|
|
|
|
|
# edit protocol in repository,
|
|
|
|
# create, edit, delete or reorder step in repository
|
|
|
|
can :update_protocol_in_repository do |user, protocol|
|
2017-12-07 01:40:49 +08:00
|
|
|
protocol.in_repository_active? &&
|
|
|
|
can_update_protocol_type_in_repository?(user, protocol)
|
|
|
|
end
|
|
|
|
|
|
|
|
# toggle protocol visibility (public, private, archive, restore)
|
|
|
|
can :update_protocol_type_in_repository do |user, protocol|
|
2017-12-07 00:23:08 +08:00
|
|
|
user.is_normal_user_or_admin_of_team?(protocol.team) &&
|
2017-12-07 01:40:49 +08:00
|
|
|
user == protocol.added_by
|
2017-12-07 00:23:08 +08:00
|
|
|
end
|
2017-12-07 18:11:27 +08:00
|
|
|
|
|
|
|
# clone protocol in repository
|
2018-01-05 22:15:50 +08:00
|
|
|
can :clone_protocol_in_repository do |user, protocol|
|
|
|
|
can_create_protocols_in_repository?(user, protocol.team) &&
|
2017-12-07 18:11:27 +08:00
|
|
|
can_read_protocol_in_repository?(user, protocol)
|
|
|
|
end
|
2017-12-06 02:51:44 +08:00
|
|
|
end
|
2017-12-20 23:05:05 +08:00
|
|
|
|
|
|
|
Canaid::Permissions.register_for(Sample) do
|
|
|
|
# edit, delete specific sample
|
|
|
|
can :update_or_delete_sample do |user, sample|
|
|
|
|
can_manage_samples?(user, sample.team)
|
|
|
|
end
|
|
|
|
end
|
2018-01-03 23:37:02 +08:00
|
|
|
|
|
|
|
Canaid::Permissions.register_for(CustomField) do
|
|
|
|
# update, delete custom field
|
|
|
|
can :update_or_delete_custom_field do |user, custom_field|
|
2018-01-05 22:15:50 +08:00
|
|
|
can_manage_sample_columns?(user, custom_field.team)
|
2018-01-03 23:37:02 +08:00
|
|
|
end
|
|
|
|
end
|
2018-01-04 18:53:58 +08:00
|
|
|
|
2018-01-05 18:17:01 +08:00
|
|
|
Canaid::Permissions.register_for(Repository) do
|
|
|
|
# edit, destroy repository
|
|
|
|
can :update_or_delete_repository do |user, repository|
|
2018-01-05 22:15:50 +08:00
|
|
|
can_create_repositories?(user, repository.team)
|
2018-01-05 18:17:01 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-01-04 18:53:58 +08:00
|
|
|
Canaid::Permissions.register_for(RepositoryRow) do
|
|
|
|
# update, delete specific repository record
|
|
|
|
can :update_or_delete_repository_row do |user, repository_row|
|
|
|
|
can_manage_repository_rows?(user, repository_row.repository.team)
|
|
|
|
end
|
|
|
|
end
|
2018-01-05 17:43:59 +08:00
|
|
|
|
|
|
|
Canaid::Permissions.register_for(RepositoryColumn) do
|
|
|
|
# update, delete repository column
|
|
|
|
can :update_or_delete_repository_column do |user, repository_column|
|
2018-01-05 22:15:50 +08:00
|
|
|
can_create_repository_columns?(user, repository_column.repository.team)
|
2018-01-05 17:43:59 +08:00
|
|
|
end
|
|
|
|
end
|
2018-01-23 15:52:10 +08:00
|
|
|
|