mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-31 12:09:17 +08:00
Minor fix
This commit is contained in:
parent
2a9f975c13
commit
280b7a0e75
2 changed files with 23 additions and 22 deletions
|
@ -1,29 +1,29 @@
|
|||
class Users::SettingsController < ApplicationController
|
||||
include UsersGenerator
|
||||
module Users
|
||||
class SettingsController < ApplicationController
|
||||
before_action :load_user, only: [
|
||||
:user_current_team
|
||||
]
|
||||
|
||||
before_action :load_user, only: [
|
||||
:user_current_team
|
||||
]
|
||||
|
||||
def user_current_team
|
||||
team_id = params[:user][:current_team_id].to_i
|
||||
if @user.teams_ids.include?(team_id)
|
||||
@user.current_team_id = team_id
|
||||
@changed_team = Team.find_by_id(@user.current_team_id)
|
||||
if @user.save
|
||||
flash[:success] = t('users.settings.changed_team_flash',
|
||||
team: @changed_team.name)
|
||||
redirect_to root_path
|
||||
return
|
||||
def user_current_team
|
||||
team_id = params[:user][:current_team_id].to_i
|
||||
if @user.teams_ids.include?(team_id)
|
||||
@user.current_team_id = team_id
|
||||
@changed_team = Team.find_by_id(@user.current_team_id)
|
||||
if @user.save
|
||||
flash[:success] = t('users.settings.changed_team_flash',
|
||||
team: @changed_team.name)
|
||||
redirect_to root_path
|
||||
return
|
||||
end
|
||||
end
|
||||
flash[:alert] = t('users.settings.changed_team_error_flash')
|
||||
redirect_to :back
|
||||
end
|
||||
flash[:alert] = t('users.settings.changed_team_error_flash')
|
||||
redirect_to :back
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def load_user
|
||||
@user = current_user
|
||||
def load_user
|
||||
@user = current_user
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,6 +40,7 @@ Rails.application.routes.draw do
|
|||
as: 'notifications_settings',
|
||||
defaults: { format: 'json' }
|
||||
|
||||
# Change user's current team
|
||||
post 'users/settings/user_current_team',
|
||||
to: 'users/settings#user_current_team',
|
||||
as: 'user_current_team'
|
||||
|
|
Loading…
Reference in a new issue