mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 13:13:22 +08:00
first run
This commit is contained in:
parent
12c77df883
commit
e02132578a
2 changed files with 18 additions and 1 deletions
|
@ -11,7 +11,8 @@ class Users::SettingsController < ApplicationController
|
||||||
:tutorial,
|
:tutorial,
|
||||||
:reset_tutorial,
|
:reset_tutorial,
|
||||||
:notifications_settings,
|
:notifications_settings,
|
||||||
:user_current_organization
|
:user_current_organization,
|
||||||
|
:destroy_user_organization
|
||||||
]
|
]
|
||||||
|
|
||||||
before_action :check_organization_permission, only: [
|
before_action :check_organization_permission, only: [
|
||||||
|
@ -401,6 +402,7 @@ class Users::SettingsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
if !invalid
|
if !invalid
|
||||||
|
reset_current_organization
|
||||||
if params[:leave] then
|
if params[:leave] then
|
||||||
flash[:notice] = I18n.t(
|
flash[:notice] = I18n.t(
|
||||||
"users.settings.organizations.index.leave_flash",
|
"users.settings.organizations.index.leave_flash",
|
||||||
|
@ -598,4 +600,15 @@ class Users::SettingsController < ApplicationController
|
||||||
UserNotification.create(notification: notification, user: target_user)
|
UserNotification.create(notification: notification, user: target_user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# checks if the user is still in the current organization
|
||||||
|
def reset_current_organization
|
||||||
|
if @user.organizations_ids.exclude? @user.current_organization_id
|
||||||
|
@user.current_organization_id = @user.organizations_ids.first
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# def reset_current_organization_of_removed_users
|
||||||
|
#
|
||||||
|
# end
|
||||||
end
|
end
|
||||||
|
|
|
@ -259,6 +259,10 @@ class User < ActiveRecord::Base
|
||||||
.uniq
|
.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def organizations_ids
|
||||||
|
organizations.pluck(:id)
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def time_zone_check
|
def time_zone_check
|
||||||
|
|
Loading…
Reference in a new issue