From 6d21b3c4aea80589c3c6bbda2957edf098e10ec9 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 15 Jan 2017 12:52:41 +0000 Subject: [PATCH] Add default timezone for new users (#16484). git-svn-id: http://svn.redmine.org/redmine/trunk@16200 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/user_preference.rb | 3 +++ app/views/settings/_authentication.html.erb | 2 ++ config/settings.yml | 2 ++ test/unit/user_preference_test.rb | 7 +++++++ 4 files changed, 14 insertions(+) diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index ed6de228b..b2d336a20 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -39,6 +39,9 @@ class UserPreference < ActiveRecord::Base if new_record? && !(attributes && attributes.key?(:hide_mail)) self.hide_mail = Setting.default_users_hide_mail? end + if new_record? && !(attributes && attributes.key?(:time_zone)) + self.time_zone = Setting.default_users_time_zone + end if new_record? && !(attributes && attributes.key?(:no_self_notified)) self.no_self_notified = true end diff --git a/app/views/settings/_authentication.html.erb b/app/views/settings/_authentication.html.erb index 15367813a..fd3c65c28 100644 --- a/app/views/settings/_authentication.html.erb +++ b/app/views/settings/_authentication.html.erb @@ -41,6 +41,8 @@

<%= setting_check_box :default_users_hide_mail, :label => :field_hide_mail %>

+ +

<%= setting_select :default_users_time_zone, ActiveSupport::TimeZone.all.collect {|z| [ z.to_s, z.name ]}, :label => :field_time_zone, :blank => :label_none %>

diff --git a/config/settings.yml b/config/settings.yml index c44da3259..bf577dedb 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -236,6 +236,8 @@ sequential_project_identifiers: # multiple values accepted, comma separated default_users_hide_mail: default: 1 +default_users_time_zone: + default: "" repositories_encodings: default: '' # encoding used to convert commit logs to UTF-8 diff --git a/test/unit/user_preference_test.rb b/test/unit/user_preference_test.rb index 7303d178f..bbf5f70ba 100644 --- a/test/unit/user_preference_test.rb +++ b/test/unit/user_preference_test.rb @@ -32,6 +32,13 @@ class UserPreferenceTest < ActiveSupport::TestCase end end + def test_time_zone_should_default_to_setting + with_settings :default_users_time_zone => 'Paris' do + preference = UserPreference.new + assert_equal 'Paris', preference.time_zone + end + end + def test_no_self_notified_should_default_to_true preference = UserPreference.new assert_equal true, preference.no_self_notified -- 2.39.5