summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-06-27 09:42:15 +0200
committerPeter Kozak <spag@golwen.net>2013-06-27 09:42:15 +0200
commitfa118e11df2913d1fcf6334b2dc3144a3b324204 (patch)
tree6a322996c87390075cb5f85d50ee7cec924211a6
parent39c06e5b4fd5a984c4f93fa48567c63848632ced (diff)
change_language_of_child_objects after changing user language
-rw-r--r--app/models/user.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 5e97459..70c9042 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -107,6 +107,8 @@ class User < ActiveRecord::Base
after_save :become_a_member_of_default_user_groups
+ after_save :change_language_of_child_objects
+
def destroy
clean_whitelist_entries
super
@@ -246,4 +248,15 @@ class User < ActiveRecord::Base
end
end
+ def change_language_of_child_objects
+ if !self.language_id_changed?
+ return nil
+ end
+
+ code = self.language.code
+ self.sip_accounts.each do |sip_account|
+ sip_account.update_attributes(:language_code => code)
+ end
+ end
+
end