Patch #222 ยป autowatch_issues.patch
app/controllers/issues_controller.rb (working copy) | ||
---|---|---|
58 | 58 |
@custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| @issue.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x, :customized => @issue) } |
59 | 59 |
else |
60 | 60 |
begin |
61 |
@issue.init_journal(self.logged_in_user) |
|
61 |
journal = @issue.init_journal(self.logged_in_user)
|
|
62 | 62 |
# Retrieve custom fields and values |
63 | 63 |
@custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) } |
64 | 64 |
@issue.custom_values = @custom_values |
65 | 65 |
@issue.attributes = params[:issue] |
66 | 66 |
if @issue.save |
67 |
@issue.add_watcher(@issue.author) if @issue.author |
|
68 |
@issue.add_watcher(@issue.assigned_to) if @issue.assigned_to |
|
69 | ||
67 | 70 |
flash[:notice] = l(:notice_successful_update) |
71 |
Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? |
|
68 | 72 |
redirect_to :action => 'show', :id => @issue |
69 | 73 |
end |
70 | 74 |
rescue ActiveRecord::StaleObjectError |
... | ... | |
104 | 108 |
:prop_key => a.id, |
105 | 109 |
:value => a.filename) unless a.new_record? |
106 | 110 |
} if params[:attachments] and params[:attachments].is_a? Array |
107 |
|
|
111 | ||
112 |
@issue.add_watcher(@issue.author) if @issue.author |
|
113 |
@issue.add_watcher(@issue.assigned_to) if @issue.assigned_to |
|
114 | ||
108 | 115 |
flash[:notice] = l(:notice_successful_update) |
109 | 116 |
Mailer.deliver_issue_edit(journal) if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled? |
110 | 117 |
redirect_to :action => 'show', :id => @issue |
app/controllers/projects_controller.rb (working copy) | ||
---|---|---|
249 | 249 |
@issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status |
250 | 250 |
|
251 | 251 |
@issue.author_id = self.logged_in_user.id if self.logged_in_user |
252 | ||
253 |
@issue.add_watcher(self.logged_in_user) if self.logged_in_user |
|
254 |
@issue.add_watcher(@issue.assigned_to) if @issue.assigned_to |
|
255 | ||
252 | 256 |
# Multiple file upload |
253 | 257 |
@attachments = [] |
254 | 258 |
params[:attachments].each { |a| |
app/models/mailer.rb (working copy) | ||
---|---|---|
29 | 29 |
def issue_add(issue) |
30 | 30 |
set_language_if_valid(Setting.default_language) |
31 | 31 |
# Sends to all project members |
32 |
@recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact |
|
32 |
@recipients = issue.watcher_recipients |
|
33 |
@recipients.push issue.assigned_to.mail if issue.assigned_to |
|
34 |
@recipients.uniq! |
|
35 |
# Managers in cc |
|
36 |
#@cc = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification && m.role.name =~ /manager/i }.compact - @recipients |
|
33 | 37 |
@from = Setting.mail_from |
34 | 38 |
@subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}" |
35 | 39 |
@body['issue'] = issue |
... | ... | |
39 | 43 |
set_language_if_valid(Setting.default_language) |
40 | 44 |
# Sends to all project members |
41 | 45 |
issue = journal.journalized |
42 |
@recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact |
|
43 |
# Watchers in cc |
|
44 |
@cc = issue.watcher_recipients - @recipients |
|
46 |
@recipients = issue.watcher_recipients |
|
47 |
@recipients.push issue.assigned_to.mail if issue.assigned_to |
|
48 |
@recipients.uniq! |
|
49 |
# Managers in cc |
|
50 |
#@cc = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification && m.role.name =~ /manager/i }.compact - @recipients |
|
45 | 51 |
@from = Setting.mail_from |
46 | 52 |
@subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}" |
47 | 53 |
@body['issue'] = issue |
db/migrate/059_set_issue_edit_notifications.rb (revision 0) | ||
---|---|---|
1 |
class SetIssueEditNotifications < ActiveRecord::Migration |
|
2 |
def self.up |
|
3 |
Permission.find_by_controller_and_action("issues", "edit").update_attribute(:mail_option, true) |
|
4 |
end |
|
5 | ||
6 |
def self.down |
|
7 |
Permission.find_by_controller_and_action("issues", "edit").update_attribute(:mail_option, false) |
|
8 |
end |
|
9 |
end |
lib/redmine/acts_as_watchable/lib/acts_as_watchable.rb (working copy) | ||
---|---|---|
23 | 23 |
end |
24 | 24 |
|
25 | 25 |
def add_watcher(user) |
26 |
self.watchers << Watcher.new(:user => user) |
|
26 |
self.watchers << Watcher.new(:user => user) unless self.watchers.member?(user)
|
|
27 | 27 |
end |
28 | 28 |
|
29 | 29 |
def remove_watcher(user) |