summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorCedric Gatay <cedric@gatay.fr>2011-12-24 17:28:20 +0100
committerCedric Gatay <cedric@gatay.fr>2011-12-24 17:28:20 +0100
commitc0b47d3245a15b12ebe7a6f4154f35ba91396c3c (patch)
treea9f99d01f42c8ac6366a5cf5902ce899ce12b598 /app
parent89a43543e9c229c223ef4d3031e83dc35e3fd3c5 (diff)
downloadgitlab-ce-c0b47d3245a15b12ebe7a6f4154f35ba91396c3c.tar.gz
Alert commit author on note
Allows to alert only the commit author when a new note is added on a commit, useful when gitlabhq is used for code reviews, allows less noise with mails...
Diffstat (limited to 'app')
-rw-r--r--app/controllers/notes_controller.rb1
-rw-r--r--app/mailers/notify.rb1
-rw-r--r--app/models/mailer_observer.rb2
-rw-r--r--app/models/note.rb5
-rw-r--r--app/views/notes/_form.html.haml6
5 files changed, 13 insertions, 2 deletions
diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb
index 5d99d1e273e..19c8571705d 100644
--- a/app/controllers/notes_controller.rb
+++ b/app/controllers/notes_controller.rb
@@ -13,6 +13,7 @@ class NotesController < ApplicationController
@note = @project.notes.new(params[:note])
@note.author = current_user
@note.notify = true if params[:notify] == '1'
+ @note.notify_author = true if params[:notify_author] == '1'
@note.save
respond_to do |format|
diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb
index 64f17232a20..729481fdbc2 100644
--- a/app/mailers/notify.rb
+++ b/app/mailers/notify.rb
@@ -28,6 +28,7 @@ class Notify < ActionMailer::Base
@note = note
@project = note.project
@commit = @project.repo.commits(note.noteable_id).first
+ return unless ( note.notify or ( note.notify_author and @commit.author.email == @user.email ) )
mail(:to => @user.email, :subject => "gitlab | #{@note.project.name} ")
end
diff --git a/app/models/mailer_observer.rb b/app/models/mailer_observer.rb
index 159f655494c..2567ccfdf72 100644
--- a/app/models/mailer_observer.rb
+++ b/app/models/mailer_observer.rb
@@ -27,7 +27,7 @@ class MailerObserver < ActiveRecord::Observer
end
def new_note(note)
- return unless note.notify
+ return unless note.notify or note.notify_author
note.project.users.reject { |u| u.id == current_user.id } .each do |u|
case note.noteable_type
when "Commit" then
diff --git a/app/models/note.rb b/app/models/note.rb
index 9a38cd77ffa..0248ceab8db 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -14,6 +14,7 @@ class Note < ActiveRecord::Base
attr_protected :author, :author_id
attr_accessor :notify
+ attr_accessor :notify_author
validates_presence_of :project
@@ -40,6 +41,10 @@ class Note < ActiveRecord::Base
def notify
@notify ||= false
end
+
+ def notify_author
+ @notify_author ||= false
+ end
end
# == Schema Information
#
diff --git a/app/views/notes/_form.html.haml b/app/views/notes/_form.html.haml
index c2aa04e2ef6..23c9553ebb1 100644
--- a/app/views/notes/_form.html.haml
+++ b/app/views/notes/_form.html.haml
@@ -23,9 +23,13 @@
%br
= f.file_field :attachment
- = check_box_tag :notify, 1, true
+ = check_box_tag :notify, 1, @note.noteable_type != "Commit"
= label_tag :notify, "Notify project team about your note"
+ -if @note.noteable_type == "Commit"
+ = check_box_tag :notify_author, 1 , @note.noteable_type == "Commit"
+ = label_tag :notify_author, "Notify commit author about your note"
+
.clear
%br
= f.submit 'Add note', :class => "grey-button", :id => "submit_note"