Merge pull request #2876 from aignatov-bio/ai-sci-5066-fix-switch-team

Fix switch team on link for object from other team [SCI-5066]
This commit is contained in:
aignatov-bio 2020-09-30 10:09:19 +02:00 committed by GitHub
commit 9010f9c1db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 2 deletions

View file

@ -83,7 +83,7 @@ class ApplicationController < ActionController::Base
private private
def update_current_team def update_current_team
current_team = Team.find_by_id(current_user.current_team_id) @current_team = Team.find_by_id(current_user.current_team_id)
if (current_team.nil? || !current_user.is_member_of_team?(current_team)) && if (current_team.nil? || !current_user.is_member_of_team?(current_team)) &&
current_user.teams.count.positive? current_user.teams.count.positive?

View file

@ -4,6 +4,7 @@ class ProjectsController < ApplicationController
include TeamsHelper include TeamsHelper
include InputSanitizeHelper include InputSanitizeHelper
before_action :switch_team_with_param, only: :index
before_action :load_vars, only: %i(show edit update before_action :load_vars, only: %i(show edit update
notifications reports notifications reports
samples experiment_archive samples experiment_archive
@ -37,7 +38,6 @@ class ProjectsController < ApplicationController
} }
end end
format.html do format.html do
current_team_switch(Team.find_by_id(params[:team])) if params[:team]
@teams = current_user.teams @teams = current_user.teams
# New project for create new project modal # New project for create new project modal
@project = Project.new @project = Project.new

View file

@ -4,6 +4,7 @@ module TeamsHelper
if team != current_team if team != current_team
current_user.current_team_id = team.id current_user.current_team_id = team.id
current_user.save current_user.save
update_current_team
end end
end end