aboutsummaryrefslogtreecommitdiffstats
path: root/app/policies/stop_area_policy.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/policies/stop_area_policy.rb')
-rw-r--r--app/policies/stop_area_policy.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/policies/stop_area_policy.rb b/app/policies/stop_area_policy.rb
index faeebbc2a..6db48b702 100644
--- a/app/policies/stop_area_policy.rb
+++ b/app/policies/stop_area_policy.rb
@@ -1,5 +1,13 @@
class StopAreaPolicy < ApplicationPolicy
class Scope < Scope
+ def search_scope scope_name
+ scope = resolve
+ if scope_name&.to_s == "route_editor"
+ scope = scope.where(area_type: 'zdep') unless user.organisation.has_feature?("route_stop_areas_all_types")
+ end
+ scope
+ end
+
def resolve
scope
end
@@ -16,4 +24,12 @@ class StopAreaPolicy < ApplicationPolicy
def update?
user.has_permission?('stop_areas.update')
end
+
+ def deactivate?
+ !record.deactivated? && user.has_permission?('stop_areas.change_status')
+ end
+
+ def activate?
+ record.deactivated? && user.has_permission?('stop_areas.change_status')
+ end
end