summaryrefslogtreecommitdiffstats
path: root/app/models/user_preference.rb
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2022-03-19 10:14:29 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2022-03-19 10:14:29 +0000
commite50190a82a5b6a066a3fadfdebf9df6e268719ad (patch)
treec49f3341b96612314a1f0e238102cce24f1aaaa7 /app/models/user_preference.rb
parent23874fa913c62f7da23f2d1fab6e5e1a445ae290 (diff)
downloadredmine-e50190a82a5b6a066a3fadfdebf9df6e268719ad.tar.gz
redmine-e50190a82a5b6a066a3fadfdebf9df6e268719ad.zip
Automatically add the user to the watchers list after contributing to an issue (#4347). User can enable/disable this feature from My Account.
Patch by Takenori TAKAKI and Jens Krämer. git-svn-id: http://svn.redmine.org/redmine/trunk@21469 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/user_preference.rb')
-rw-r--r--app/models/user_preference.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb
index a0fea2851..758736824 100644
--- a/app/models/user_preference.rb
+++ b/app/models/user_preference.rb
@@ -39,10 +39,12 @@ class UserPreference < ActiveRecord::Base
'history_default_tab',
'default_issue_query',
'default_project_query',
- 'toolbar_language_options')
+ 'toolbar_language_options',
+ 'auto_watch_on')
TEXTAREA_FONT_OPTIONS = ['monospace', 'proportional']
DEFAULT_TOOLBAR_LANGUAGE_OPTIONS = %w[c cpp csharp css diff go groovy html java javascript objc perl php python r ruby sass scala shell sql swift xml yaml]
+ AUTO_WATCH_ON_OPTIONS = ['issue_contributed_to']
def initialize(attributes=nil, *args)
super
@@ -56,6 +58,9 @@ class UserPreference < ActiveRecord::Base
unless attributes && attributes.key?(:no_self_notified)
self.no_self_notified = Setting.default_users_no_self_notified
end
+ unless attributes && attributes.key?(:auto_watch_on)
+ self.auto_watch_on = AUTO_WATCH_ON_OPTIONS
+ end
end
self.others ||= {}
end
@@ -124,6 +129,10 @@ class UserPreference < ActiveRecord::Base
def default_project_query; self[:default_project_query] end
def default_project_query=(value); self[:default_project_query]=value; end
+ def auto_watch_on; self[:auto_watch_on] || []; end
+ def auto_watch_on=(values); self[:auto_watch_on]=values; end
+ def auto_watch_on?(action); self.auto_watch_on.include?(action.to_s); end
+
# Returns the names of groups that are displayed on user's page
# Example:
# preferences.my_page_groups