mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 01:44:34 +08:00
43 lines
1.3 KiB
Ruby
43 lines
1.3 KiB
Ruby
Canaid::Permissions.register_for(Team) do
|
|
# view projects, view protocols
|
|
can :read_team do |user, team|
|
|
user.is_member_of_team?(team)
|
|
end
|
|
|
|
# edit team name, edit team description
|
|
can :update_team do |user, team|
|
|
user.is_admin_of_team?(team)
|
|
end
|
|
|
|
# invite user to team
|
|
can :create_user_team do |user, team|
|
|
user.is_admin_of_team?(team)
|
|
end
|
|
|
|
# create protocol in repository, import protocol to repository
|
|
can :create_protocol do |user, team|
|
|
user.is_normal_user_or_admin_of_team?(team)
|
|
end
|
|
|
|
# create sample, import sample
|
|
can :create_sample do |user, team|
|
|
user.is_normal_user_or_admin_of_team?(team)
|
|
end
|
|
end
|
|
|
|
Canaid::Permissions.register_for(UserTeam) do
|
|
# change user's role, remove user from team, leave team
|
|
can :update_or_delete_user_team do |user, user_team|
|
|
user == user_team.user || user.is_admin_of_team?(user_team.team)
|
|
end
|
|
end
|
|
|
|
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
|
|
end
|