From b26530a02f0020e54807433507f361d395c93976 Mon Sep 17 00:00:00 2001 From: Zanz2 Date: Tue, 28 Aug 2018 14:48:23 +0200 Subject: [PATCH 1/2] Found a new, and more elegant fix inside controller with Luka --- app/controllers/experiments_controller.rb | 2 ++ app/controllers/my_modules_controller.rb | 3 +++ app/controllers/projects_controller.rb | 4 +++- app/controllers/protocols_controller.rb | 6 +++++- app/helpers/search_helper.rb | 4 ++-- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/controllers/experiments_controller.rb b/app/controllers/experiments_controller.rb index a7dce3b7d..7c5a51381 100644 --- a/app/controllers/experiments_controller.rb +++ b/app/controllers/experiments_controller.rb @@ -349,6 +349,8 @@ class ExperimentsController < ApplicationController end def load_projects_tree + # Switch to correct team + current_team_switch(@experiment.project.team) unless @experiment.project.nil? @projects_tree = current_user.projects_tree(current_team, nil) end diff --git a/app/controllers/my_modules_controller.rb b/app/controllers/my_modules_controller.rb index 1e372fc6d..5b0ef6a0a 100644 --- a/app/controllers/my_modules_controller.rb +++ b/app/controllers/my_modules_controller.rb @@ -266,6 +266,7 @@ class MyModulesController < ApplicationController def repository @repository = Repository.find_by_id(params[:repository_id]) render_403 if @repository.nil? || !can_read_team?(@repository.team) + current_team_switch(@repository.team) end def archive @@ -661,6 +662,8 @@ class MyModulesController < ApplicationController end def load_projects_tree + # Switch to correct team + current_team_switch(@project.team) unless @project.nil? @projects_tree = current_user.projects_tree(current_team, nil) end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index ba78e9ed4..c8be39086 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -248,7 +248,6 @@ class ProjectsController < ApplicationController @project.save end # This is the "info" view - current_team_switch(@project.team) @current_sort = @project.experiments_order end @@ -316,6 +315,9 @@ class ProjectsController < ApplicationController end def load_projects_tree + # Switch to correct team + current_team_switch(@project.team) unless @project.nil? + if current_user.teams.any? @current_team = current_team if current_team diff --git a/app/controllers/protocols_controller.rb b/app/controllers/protocols_controller.rb index 219cb4a97..fd5cd3136 100644 --- a/app/controllers/protocols_controller.rb +++ b/app/controllers/protocols_controller.rb @@ -5,6 +5,7 @@ class ProtocolsController < ApplicationController include ProtocolsExporter include InputSanitizeHelper include ProtocolsIoHelper + include TeamsHelper before_action :check_create_permissions, only: %i( create_new_modal @@ -142,7 +143,10 @@ class ProtocolsController < ApplicationController move_protocol('restore') end - def edit; end + def edit + # Switch to correct team + current_team_switch(@protocol.team) + end def update_metadata @protocol.record_timestamps = false diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index cf610122d..64920b847 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -11,11 +11,11 @@ module SearchHelper if search_team != current_team link_to text, path, - data: { no_turbolink: true, + data: { turbolinks: false, confirm: t('users.settings.changed_team_in_search', team: search_team.name) } else - link_to text, path, data: { no_turbolink: true } + link_to text, path, data: { turbolinks: false } end end From 728b1fe4914f89c4f31a63e9a2415d9b68b2a23d Mon Sep 17 00:00:00 2001 From: Zanz2 Date: Tue, 28 Aug 2018 14:51:05 +0200 Subject: [PATCH 2/2] Reverted deleted lines by accident --- app/controllers/projects_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index c8be39086..c9a96cc80 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -248,6 +248,7 @@ class ProjectsController < ApplicationController @project.save end # This is the "info" view + current_team_switch(@project.team) @current_sort = @project.experiments_order end @@ -317,7 +318,6 @@ class ProjectsController < ApplicationController def load_projects_tree # Switch to correct team current_team_switch(@project.team) unless @project.nil? - if current_user.teams.any? @current_team = current_team if current_team