From bb9c03df245eadcec9ee23f35117c5e1238c7d42 Mon Sep 17 00:00:00 2001 From: zmagod Date: Tue, 11 Oct 2016 16:46:30 +0200 Subject: [PATCH] fixes controllers --- app/controllers/experiments_controller.rb | 2 ++ app/controllers/my_modules_controller.rb | 10 +++++++++- app/controllers/projects_controller.rb | 1 + app/controllers/reports_controller.rb | 3 ++- app/controllers/sample_my_modules_controller.rb | 4 ++++ app/helpers/organizations_helper.rb | 2 +- .../search/results/partials/_report_text.html.erb | 3 --- 7 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/controllers/experiments_controller.rb b/app/controllers/experiments_controller.rb index e8f11ceb2..d4495744b 100644 --- a/app/controllers/experiments_controller.rb +++ b/app/controllers/experiments_controller.rb @@ -1,5 +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 17c2fec7d..91adc470b 100644 --- a/app/controllers/my_modules_controller.rb +++ b/app/controllers/my_modules_controller.rb @@ -232,10 +232,14 @@ class MyModulesController < ApplicationController def protocols @protocol = @my_module.protocol + current_organization_switch(@protocol.organization) end def results - + current_organization_switch(@my_module + .experiment + .project + .organization) end def samples @@ -245,6 +249,10 @@ class MyModulesController < ApplicationController def archive @archived_results = @my_module.archived_results + current_organization_switch(@my_module + .experiment + .project + .organization) end # Submit actions diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 556445a36..d58dd52dd 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -1,6 +1,7 @@ class ProjectsController < ApplicationController include SampleActions include RenamingUtil + include OrganizationsHelper before_action :load_vars, only: [:show, :edit, :update, :notifications, :reports, diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 17ed7145c..72347bc99 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -99,9 +99,10 @@ class ReportsController < ApplicationController def edit # cleans all the deleted report + current_organization_switch(@report.project.organization) @report.cleanup_report load_markdown - render "reports/new.html.erb" + render 'reports/new.html.erb' end # Updating existing report from the _save modal of the new page diff --git a/app/controllers/sample_my_modules_controller.rb b/app/controllers/sample_my_modules_controller.rb index 75568256c..c3c488ed4 100644 --- a/app/controllers/sample_my_modules_controller.rb +++ b/app/controllers/sample_my_modules_controller.rb @@ -5,6 +5,10 @@ class SampleMyModulesController < ApplicationController @number_of_samples = @my_module.number_of_samples @samples = @my_module.first_n_samples + current_organization_switch(@my_module + .experiment + .project + .organization) respond_to do |format| format.json { render :json => { diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index f83ea5d8a..429acdac2 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -1,6 +1,6 @@ module OrganizationsHelper + # resets the current organization if needed def current_organization_switch(org) - # resets the current organization if needed if org != current_organization current_user.current_organization_id = org.id current_user.save diff --git a/app/views/search/results/partials/_report_text.html.erb b/app/views/search/results/partials/_report_text.html.erb index 2335b7920..0686c885a 100644 --- a/app/views/search/results/partials/_report_text.html.erb +++ b/app/views/search/results/partials/_report_text.html.erb @@ -2,9 +2,6 @@ <% text = query.present? ? highlight(report.name, query.strip.split(/\s+/)) : report.name %> <% if can_view_reports(report.project) %> - - <%= text %> - <%= route_to_other_org edit_project_report_path(report.project, report), report.project.organization, text %>