From 3117a464f0a5f5f000cebd71dae67cbbdb3431f8 Mon Sep 17 00:00:00 2001 From: zmagod Date: Wed, 12 Oct 2016 09:30:55 +0200 Subject: [PATCH] fixed controllers --- app/controllers/experiments_controller.rb | 2 +- app/controllers/my_modules_controller.rb | 1 + app/controllers/projects_controller.rb | 5 +++++ app/controllers/reports_controller.rb | 1 + app/controllers/sample_my_modules_controller.rb | 1 + app/controllers/samples_controller.rb | 2 +- 6 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/controllers/experiments_controller.rb b/app/controllers/experiments_controller.rb index d4495744b..f181505da 100644 --- a/app/controllers/experiments_controller.rb +++ b/app/controllers/experiments_controller.rb @@ -1,7 +1,7 @@ class ExperimentsController < ApplicationController include PermissionHelper include OrganizationsHelper - + before_action :set_experiment, except: [:new, :create] before_action :set_project, diff --git a/app/controllers/my_modules_controller.rb b/app/controllers/my_modules_controller.rb index 91adc470b..0fdd0b23d 100644 --- a/app/controllers/my_modules_controller.rb +++ b/app/controllers/my_modules_controller.rb @@ -1,5 +1,6 @@ class MyModulesController < ApplicationController include SampleActions + include OrganizationsHelper before_action :load_vars, only: [ :show, :edit, :update, :destroy, diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index d58dd52dd..4188d5d9e 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -24,6 +24,11 @@ class ProjectsController < ApplicationController DELETE_SAMPLES = I18n.t("samples.delete_samples") def index + if params[:organization] + current_organization_switch(Organization + .find_by_id(params[:organization])) + end + @current_organization_id = current_organization.id @current_sort = params[:sort].to_s @projects_by_orgs = current_user.projects_by_orgs(@current_organization_id, diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 72347bc99..cdfaf700f 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -1,4 +1,5 @@ class ReportsController < ApplicationController + include OrganizationsHelper # Ignore CSRF protection just for PDF generation (because it's # used via target='_blank') protect_from_forgery with: :exception, :except => :generate diff --git a/app/controllers/sample_my_modules_controller.rb b/app/controllers/sample_my_modules_controller.rb index c3c488ed4..f42b120ee 100644 --- a/app/controllers/sample_my_modules_controller.rb +++ b/app/controllers/sample_my_modules_controller.rb @@ -1,4 +1,5 @@ class SampleMyModulesController < ApplicationController + include OrganizationsHelper before_action :load_vars def index diff --git a/app/controllers/samples_controller.rb b/app/controllers/samples_controller.rb index d90f99042..086d55c2e 100644 --- a/app/controllers/samples_controller.rb +++ b/app/controllers/samples_controller.rb @@ -279,7 +279,7 @@ class SamplesController < ApplicationController def load_vars @sample = Sample.find_by_id(params[:id]) - @organization = @sample.organization + @organization = current_organization unless @sample render_404