From e9f087ca379dd5b8f26dc96bcfb5d23cd5951662 Mon Sep 17 00:00:00 2001 From: Zog Date: Fri, 27 Apr 2018 10:35:19 +0200 Subject: Refs #6572; Fix referentials policies --- app/controllers/referentials_controller.rb | 2 +- app/decorators/referential_decorator.rb | 6 +++--- app/policies/application_policy.rb | 2 +- 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 -- cgit v1.2.3