aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZog2018-04-27 10:35:19 +0200
committerJohan Van Ryseghem2018-04-27 11:17:19 +0200
commite9f087ca379dd5b8f26dc96bcfb5d23cd5951662 (patch)
treef9e7d3fbcd1bd25fb636ed36699136818313e34c
parent5efc3e3b6ffb0625c05d8b692740a715e2f00925 (diff)
downloadchouette-core-e9f087ca379dd5b8f26dc96bcfb5d23cd5951662.tar.bz2
Refs #6572; Fix referentials policies
-rw-r--r--app/controllers/referentials_controller.rb2
-rw-r--r--app/decorators/referential_decorator.rb6
-rw-r--r--app/policies/application_policy.rb2
3 files changed, 5 insertions, 5 deletions
diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb
index fe661651e..8addfbc32 100644
--- a/app/controllers/referentials_controller.rb
+++ b/app/controllers/referentials_controller.rb
@@ -31,7 +31,7 @@ class ReferentialsController < ChouetteController
end
def show
- resource.switch
+ resource.switch if resource.ready?
show! do |format|
@referential = @referential.decorate()
@reflines = lines_collection.paginate(page: params[:page], per_page: 10)
diff --git a/app/decorators/referential_decorator.rb b/app/decorators/referential_decorator.rb
index cce14d160..e01987e59 100644
--- a/app/decorators/referential_decorator.rb
+++ b/app/decorators/referential_decorator.rb
@@ -5,17 +5,17 @@ class ReferentialDecorator < AF83::Decorator
instance_decorator.show_action_link
instance_decorator.edit_action_link
- instance_decorator.action_link feature: :referential_vehicle_journeys, secondary: :show, on: :show do |l|
+ instance_decorator.action_link feature: :referential_vehicle_journeys, secondary: :show, on: :show, policy: :browse do |l|
l.content t('referential_vehicle_journeys.index.title')
l.href { h.referential_vehicle_journeys_path(object) }
end
- instance_decorator.action_link feature: :purchase_windows, secondary: :show, on: :show do |l|
+ instance_decorator.action_link feature: :purchase_windows, secondary: :show, on: :show, policy: :browse do |l|
l.content t('purchase_windows.index.title')
l.href { h.referential_purchase_windows_path(object) }
end
- instance_decorator.action_link secondary: :show do |l|
+ instance_decorator.action_link secondary: :show, policy: :browse do |l|
l.content t('time_tables.index.title')
l.href { h.referential_time_tables_path(object) }
end
diff --git a/app/policies/application_policy.rb b/app/policies/application_policy.rb
index 33d88660c..05bb39ee4 100644
--- a/app/policies/application_policy.rb
+++ b/app/policies/application_policy.rb
@@ -100,7 +100,7 @@ class ApplicationPolicy
# -------
def referential
- @referential ||= current_referential || record_referential
+ @referential ||= record.is_a?(Referential) && record || current_referential || record_referential
end
def record_referential