diff options
| author | Robert | 2017-11-29 18:17:38 +0100 |
|---|---|---|
| committer | Robert | 2017-11-29 18:17:38 +0100 |
| commit | 42b6bcdf4b6a378d53e377e9a350b5f0d66a3202 (patch) | |
| tree | 07617ae120431104edf3f7f5e0b1b90607b754d6 /app | |
| parent | e0a3661e0946f634c7733a5ab932e7f695597ce1 (diff) | |
| download | chouette-core-4824-create_line_referentials.tar.bz2 | |
Fixes: #4824@0.5h; Implemented Policies4824-create_line_referentials
Diffstat (limited to 'app')
| -rw-r--r-- | app/policies/company_policy.rb | 20 | ||||
| -rw-r--r-- | app/policies/line_policy.rb | 12 | ||||
| -rw-r--r-- | app/policies/network_policy.rb | 11 | ||||
| -rw-r--r-- | app/policies/stop_area_policy.rb | 12 |
4 files changed, 51 insertions, 4 deletions
diff --git a/app/policies/company_policy.rb b/app/policies/company_policy.rb index 45386aba4..eb2b868d9 100644 --- a/app/policies/company_policy.rb +++ b/app/policies/company_policy.rb @@ -1,7 +1,19 @@ class CompanyPolicy < ApplicationPolicy - class Scope < Scope - def resolve - scope - end + class Scope < Scope + def resolve + scope end end + + def create? + !archived? && organisation_match? && user.has_permission?('companies.create') + end + + def update? + !archived? && organisation_match? && user.has_permission?('companies.update') + end + + def destroy? + !archived? && organisation_match? && user.has_permission?('companies.destroy') + end +end diff --git a/app/policies/line_policy.rb b/app/policies/line_policy.rb index acb0d79e7..a39beb788 100644 --- a/app/policies/line_policy.rb +++ b/app/policies/line_policy.rb @@ -6,6 +6,18 @@ class LinePolicy < ApplicationPolicy end end + def create? + !archived? && organisation_match? && user.has_permission?('lines.create') + end + + def update? + !archived? && organisation_match? && user.has_permission?('lines.update') + end + + def destroy? + !archived? && organisation_match? && user.has_permission?('lines.destroy') + end + def create_footnote? !archived? && organisation_match? && user.has_permission?('footnotes.create') end diff --git a/app/policies/network_policy.rb b/app/policies/network_policy.rb index 9f86451a5..7adc48589 100644 --- a/app/policies/network_policy.rb +++ b/app/policies/network_policy.rb @@ -4,4 +4,15 @@ class NetworkPolicy < ApplicationPolicy scope end end + def create? + !archived? && organisation_match? && user.has_permission?('networks.create') + end + + def update? + !archived? && organisation_match? && user.has_permission?('networks.update') + end + + def destroy? + !archived? && organisation_match? && user.has_permission?('networks.destroy') + end end diff --git a/app/policies/stop_area_policy.rb b/app/policies/stop_area_policy.rb index de8ecda8d..6f147efef 100644 --- a/app/policies/stop_area_policy.rb +++ b/app/policies/stop_area_policy.rb @@ -4,4 +4,16 @@ class StopAreaPolicy < ApplicationPolicy scope end end + + def create? + !archived? && organisation_match? && user.has_permission?('stop_areas.create') + end + + def update? + !archived? && organisation_match? && user.has_permission?('stop_areas.update') + end + + def destroy? + !archived? && organisation_match? && user.has_permission?('stop_areas.destroy') + end end |
