diff options
author | Valery Sizov <vsv2711@gmail.com> | 2011-12-18 15:46:06 +0200 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2011-12-18 15:46:06 +0200 |
commit | df5b192e4d864cc8b27976bfc814a5e445ae8e1d (patch) | |
tree | 1e06675c4e4248253637ceb661add80d4ac69f95 | |
parent | db582b638382f15f7e373fd79b90e4fc0f494a37 (diff) | |
download | gitlab-ce-df5b192e4d864cc8b27976bfc814a5e445ae8e1d.tar.gz |
notification when merge request reassigned
-rw-r--r-- | app/mailers/notify.rb | 8 | ||||
-rw-r--r-- | app/models/mailer_observer.rb | 16 | ||||
-rw-r--r-- | app/views/notify/changed_merge_request_email.html.haml | 16 |
3 files changed, 40 insertions, 0 deletions
diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index 2fb4e6a1fbc..cbc895465b0 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -45,4 +45,12 @@ class Notify < ActionMailer::Base @project = merge_request.project mail(:to => @user.email, :subject => "gitlab | #{@merge_request.title} ") end + + def changed_merge_request_email(user, merge_request) + @user = user + @assignee_was ||= User.find(merge_request.assignee_id_was) + @merge_request = merge_request + @project = merge_request.project + mail(:to => @user.email, :subject => "gitlab | #{@merge_request.title} ") + end end diff --git a/app/models/mailer_observer.rb b/app/models/mailer_observer.rb index cc63e5abb4b..39081fdae04 100644 --- a/app/models/mailer_observer.rb +++ b/app/models/mailer_observer.rb @@ -9,6 +9,10 @@ class MailerObserver < ActiveRecord::Observer new_merge_request(model) if model.kind_of?(MergeRequest) end + def after_update(model) + changed_merge_request(model) if model.kind_of?(MergeRequest) + end + protected def new_issue(issue) @@ -45,4 +49,16 @@ class MailerObserver < ActiveRecord::Observer end end + def changed_merge_request(merge_request) + if merge_request.assignee_id_changed? + recipients_ids = [merge_request.assignee_id_was] + recipients_ids << merge_request.assignee_id + recipients_ids.delete current_user.id + + User.find(recipients_ids).each do |user| + Notify.changed_merge_request_email(user, merge_request).deliver + end + end + end + end diff --git a/app/views/notify/changed_merge_request_email.html.haml b/app/views/notify/changed_merge_request_email.html.haml new file mode 100644 index 00000000000..403d51232a9 --- /dev/null +++ b/app/views/notify/changed_merge_request_email.html.haml @@ -0,0 +1,16 @@ +%td.content{:align => "left", :style => "font-family: Helvetica, Arial, sans-serif; padding: 20px 0 0;", :valign => "top", :width => "600"} + %table{:border => "0", :cellpadding => "0", :cellspacing => "0", :style => "color: #717171; font: normal 11px Helvetica, Arial, sans-serif; margin: 0; padding: 0;", :width => "600"} + %tr + %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} + %td{:align => "left", :style => "padding: 20px 0 0;"} + %h2{:style => "color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "} + Reassigned Merge Request + = link_to truncate(@merge_request.title, :length => 16), project_merge_request_url(@project, @merge_request) + %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} + %tr + %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} + %td{:style => "padding: 15px 0 15px;", :valign => "top"} + %p{:style => "color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "} + Assignee changed from #{@assignee_was.name} to #{@merge_request.assignee.name} + %td + |