aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/policies/company_policy.rb20
-rw-r--r--app/policies/line_policy.rb12
-rw-r--r--app/policies/network_policy.rb11
-rw-r--r--app/policies/stop_area_policy.rb12
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