diff options
| author | Zog | 2018-02-08 10:33:46 +0100 |
|---|---|---|
| committer | Luc Donnet | 2018-02-20 10:20:18 +0100 |
| commit | 3dcea81c627c1c740630ce7306bac55256ce8037 (patch) | |
| tree | 1ff79bdb5f04aba4503b47c781aaa0146d1ac32a /app/controllers | |
| parent | 3809301116aec5466445b29637026804da3d6745 (diff) | |
| download | chouette-core-3dcea81c627c1c740630ce7306bac55256ce8037.tar.bz2 | |
Refs #5863 @6h; Remove workbench id from the querystring
Infer it when possible, and use a nested otherwise
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/application_controller.rb | 10 | ||||
| -rw-r--r-- | app/controllers/referentials_controller.rb | 12 |
2 files changed, 10 insertions, 12 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8bd3da2f9..45b7f55f6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -36,16 +36,6 @@ class ApplicationController < ActionController::Base end helper_method :current_organisation - def current_offer_workbench - current_organisation.workbenches.find_by_name("Gestion de l'offre") - end - helper_method :current_offer_workbench - - def current_workgroup - current_offer_workbench.workgroup - end - helper_method :current_workgroup - def current_functional_scope functional_scope = current_organisation.sso_attributes.try(:[], "functional_scope") if current_organisation JSON.parse(functional_scope) if functional_scope diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 0ed3f75dd..5267c15d8 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -1,5 +1,6 @@ class ReferentialsController < ChouetteController defaults :resource_class => Referential + before_action :load_workbench include PolicyChecker respond_to :html @@ -30,7 +31,7 @@ class ReferentialsController < ChouetteController def show resource.switch show! do |format| - @referential = @referential.decorate(context: { current_workbench_id: params[:current_workbench_id] } ) + @referential = @referential.decorate() @reflines = lines_collection.paginate(page: params[:page], per_page: 10) @reflines = ReferentialLineDecorator.decorate( @reflines, @@ -141,7 +142,6 @@ class ReferentialsController < ChouetteController if params[:from] source_referential = Referential.find(params[:from]) @referential = Referential.new_from(source_referential, current_functional_scope) - @referential.workbench_id = params[:current_workbench_id] end @referential.data_format = current_organisation.data_format @@ -175,4 +175,12 @@ class ReferentialsController < ChouetteController ) end + def load_workbench + @workbench ||= Workbench.find(params[:workbench_id]) if params[:workbench_id] + @workbench ||= resource&.workbench if params[:id] + @workbench + end + + alias_method :current_workbench, :load_workbench + helper_method :current_workbench end |
