Notification when created merge request
This commit is contained in:
parent
7713f7fefb
commit
db582b6383
3 changed files with 35 additions and 1 deletions
|
@ -38,4 +38,11 @@ class Notify < ActionMailer::Base
|
|||
@issue = note.noteable
|
||||
mail(:to => @user.email, :subject => "gitlab | #{@note.project.name} ")
|
||||
end
|
||||
|
||||
def new_merge_request_email(merge_request)
|
||||
@user = merge_request.assignee
|
||||
@merge_request = merge_request
|
||||
@project = merge_request.project
|
||||
mail(:to => @user.email, :subject => "gitlab | #{@merge_request.title} ")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
class MailerObserver < ActiveRecord::Observer
|
||||
observe :issue, :user, :note, :snippet
|
||||
observe :issue, :user, :note, :merge_request
|
||||
cattr_accessor :current_user
|
||||
|
||||
def after_create(model)
|
||||
new_issue(model) if model.kind_of?(Issue)
|
||||
new_user(model) if model.kind_of?(User)
|
||||
new_note(model) if model.kind_of?(Note)
|
||||
new_merge_request(model) if model.kind_of?(MergeRequest)
|
||||
end
|
||||
|
||||
protected
|
||||
|
@ -38,4 +39,10 @@ class MailerObserver < ActiveRecord::Observer
|
|||
end
|
||||
end
|
||||
|
||||
def new_merge_request(merge_request)
|
||||
if merge_request.assignee != current_user
|
||||
Notify.new_merge_request_email(merge_request).deliver
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
20
app/views/notify/new_merge_request_email.html.haml
Normal file
20
app/views/notify/new_merge_request_email.html.haml
Normal file
|
@ -0,0 +1,20 @@
|
|||
%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; "}
|
||||
New 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; "}
|
||||
Branches: #{@merge_request.source_branch} → #{@merge_request.target_branch}
|
||||
|
||||
%p{:style => "color:#767676; font-weight: normal; margin: 0; padding: 0; line-height: 20px; font-size: 12px;font-family: Helvetica, Arial, sans-serif; "}
|
||||
Asignee: #{@merge_request.author.name} → #{@merge_request.assignee.name}
|
||||
|
||||
%td
|
||||
|
Loading…
Add table
Reference in a new issue