diff options
| author | cedricnjanga | 2017-09-05 14:26:20 +0200 |
|---|---|---|
| committer | cedricnjanga | 2017-09-05 14:36:47 +0200 |
| commit | df7552799d16d5686e389e484a00e0a7e8fb4e1d (patch) | |
| tree | a8fb56d2e41aef844cdfb5790417eaba07430fb8 /app/controllers | |
| parent | 70e8e93b0ebf4596c0ffd64620415db2450f4595 (diff) | |
| download | chouette-core-df7552799d16d5686e389e484a00e0a7e8fb4e1d.tar.bz2 | |
Referential#new_from :
Added params to certains paths to have the workbench_id in it.
The goal is to have the current workbench_id to assign it when do a Referential#new_from
Then I finished the use of the functional scope to avoid potential errors
I skipped some tests that hve a #TODO so we can easily find them
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/application_controller.rb | 3 | ||||
| -rw-r--r-- | app/controllers/referentials_controller.rb | 3 | ||||
| -rw-r--r-- | app/controllers/workbenches_controller.rb | 9 |
3 files changed, 10 insertions, 5 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 47b54039c..cc1c30703 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -34,7 +34,8 @@ class ApplicationController < ActionController::Base helper_method :current_organisation def current_functional_scope - JSON.parse(current_organisation.sso_attributes["functional_scope"]) if current_organisation + functional_scope = current_organisation.sso_attributes.try(:[], "functional_scope") if current_organisation + JSON.parse(functional_scope) if functional_scope end helper_method :current_functional_scope diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index a6dfaf2b6..bd0544a74 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -10,7 +10,6 @@ class ReferentialsController < BreadcrumbController if params[:from] source_referential = Referential.find(params[:from]) @referential = Referential.new_from(source_referential, current_functional_scope) - @referential.workbench_id = current_organisation.workbenches.first.id end new! do @@ -26,7 +25,7 @@ class ReferentialsController < BreadcrumbController def show resource.switch show! do |format| - @referential = @referential.decorate + @referential = @referential.decorate(context: { workbench_id: params[:workbench_id] } ) @reflines = lines_collection.paginate(page: params[:page], per_page: 10) @reflines = ModelDecorator.decorate( @reflines, diff --git a/app/controllers/workbenches_controller.rb b/app/controllers/workbenches_controller.rb index 19af28a98..bae3fcff2 100644 --- a/app/controllers/workbenches_controller.rb +++ b/app/controllers/workbenches_controller.rb @@ -20,8 +20,13 @@ class WorkbenchesController < BreadcrumbController @q_for_form = scope.ransack(params[:q]) @q_for_result = scope.ransack(ransack_params) @wbench_refs = sort_result(@q_for_result.result).paginate(page: params[:page], per_page: 30) - @wbench_refs = ModelDecorator.decorate(@wbench_refs, with: ReferentialDecorator) - + @wbench_refs = ModelDecorator.decorate( + @wbench_refs, + with: ReferentialDecorator, + context: { + workbench_id: params[:id] + } + ) show! do build_breadcrumb :show end |
