diff options
| author | Vlatka Pavisic | 2017-02-06 11:42:12 +0100 |
|---|---|---|
| committer | Vlatka Pavisic | 2017-02-07 11:25:29 +0100 |
| commit | d94b1271d147fdb5bbd1e616e116173198e858db (patch) | |
| tree | e1b5631e72e009ffd80fdf4e47159b2b11cd899e /app/policies/connection_link_policy.rb | |
| parent | 9c3095c20aaef122212ed71ce8818e3a18b13308 (diff) | |
| download | chouette-core-d94b1271d147fdb5bbd1e616e116173198e858db.tar.bz2 | |
Refs #2476 : Disable modification and deletion of resources from another referential; in progress
Diffstat (limited to 'app/policies/connection_link_policy.rb')
| -rw-r--r-- | app/policies/connection_link_policy.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/policies/connection_link_policy.rb b/app/policies/connection_link_policy.rb new file mode 100644 index 000000000..cc49f575f --- /dev/null +++ b/app/policies/connection_link_policy.rb @@ -0,0 +1,22 @@ +class ConnectionLinkPolicy < ApplicationPolicy + class Scope < Scope + def resolve + scope + end + end + + def create? + user.has_permission?('connection_links.create') # organisation match via referential is checked in the view + end + + def edit? + organisation_match?(via_referential: true) && user.has_permission?('connection_links.edit') + end + + def destroy? + organisation_match?(via_referential: true) && user.has_permission?('connection_links.destroy') + end + + def update? ; edit? end + def new? ; create? end +end |
