Fixed issue #429, user.preferences['locale'] not initialized at user creation.
This commit is contained in:
parent
1c7278d8be
commit
777dce4c87
1 changed files with 13 additions and 1 deletions
|
@ -38,7 +38,7 @@ class User < ApplicationModel
|
||||||
include User::SearchIndex
|
include User::SearchIndex
|
||||||
|
|
||||||
before_validation :check_name, :check_email, :check_login, :ensure_password
|
before_validation :check_name, :check_email, :check_login, :ensure_password
|
||||||
before_create :check_preferences_default, :validate_roles, :domain_based_assignment
|
before_create :check_preferences_default, :validate_roles, :domain_based_assignment, :set_locale
|
||||||
before_update :check_preferences_default, :validate_roles
|
before_update :check_preferences_default, :validate_roles
|
||||||
after_create :avatar_for_email_check
|
after_create :avatar_for_email_check
|
||||||
after_update :avatar_for_email_check
|
after_update :avatar_for_email_check
|
||||||
|
@ -881,6 +881,18 @@ returns
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# sets locale of the user
|
||||||
|
def set_locale
|
||||||
|
|
||||||
|
# set the user's locale to the one of the "executing" user
|
||||||
|
return if !UserInfo.current_user_id
|
||||||
|
user = User.find_by( id: UserInfo.current_user_id )
|
||||||
|
return if !user
|
||||||
|
return if !user.preferences[:locale]
|
||||||
|
|
||||||
|
self.preferences[:locale] = user.preferences[:locale]
|
||||||
|
end
|
||||||
|
|
||||||
def avatar_for_email_check
|
def avatar_for_email_check
|
||||||
return if email.blank?
|
return if email.blank?
|
||||||
return if email !~ /@/
|
return if email !~ /@/
|
||||||
|
|
Loading…
Reference in a new issue