Send e-Mail to all commenters if thank you note is given
This commit is contained in:
@ -37,6 +37,13 @@ class RequestForCommentsController < ApplicationController
|
|||||||
def set_thank_you_note
|
def set_thank_you_note
|
||||||
authorize!
|
authorize!
|
||||||
@request_for_comment.thank_you_note = params[:note]
|
@request_for_comment.thank_you_note = params[:note]
|
||||||
|
commenters = []
|
||||||
|
@request_for_comment.comments.distinct.to_a.each {|comment|
|
||||||
|
commenters.append comment.user
|
||||||
|
}
|
||||||
|
commenters = commenters.uniq {|user| user.id}
|
||||||
|
commenters.each {|commenter| UserMailer.send_thank_you_note(@request_for_comment, commenter).deliver_now}
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @request_for_comment.save
|
if @request_for_comment.save
|
||||||
format.json { render :show, status: :ok, location: @request_for_comment }
|
format.json { render :show, status: :ok, location: @request_for_comment }
|
||||||
|
@ -20,4 +20,12 @@ class UserMailer < ActionMailer::Base
|
|||||||
@rfc_link = request_for_comment_url(request_for_comment)
|
@rfc_link = request_for_comment_url(request_for_comment)
|
||||||
mail(subject: t('mailers.user_mailer.got_new_comment.subject', commenting_user_displayname: @commenting_user_displayname), to: request_for_comment.user.email)
|
mail(subject: t('mailers.user_mailer.got_new_comment.subject', commenting_user_displayname: @commenting_user_displayname), to: request_for_comment.user.email)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def send_thank_you_note(request_for_comments, receiver)
|
||||||
|
@receiver_displayname = receiver.displayname
|
||||||
|
@author = request_for_comments.user.displayname
|
||||||
|
@thank_you_note = request_for_comments.thank_you_note
|
||||||
|
@rfc_link = request_for_comment_url(request_for_comments)
|
||||||
|
mail(subject: t('mailers.user_mailer.send_thank_you_note.subject', author: @author), to: receiver.email)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
1
app/views/user_mailer/send_thank_you_note.slim
Normal file
1
app/views/user_mailer/send_thank_you_note.slim
Normal file
@ -0,0 +1 @@
|
|||||||
|
== t('mailers.user_mailer.send_thank_you_note.body', receiver_displayname: @receiver_displayname, link_to_comment: link_to(@rfc_link, @rfc_link), author: @author, thank_you_note: @thank_you_note )
|
@ -410,6 +410,41 @@ de:
|
|||||||
reset_password:
|
reset_password:
|
||||||
body: 'Bitte besuchen Sie %{link}, sofern Sie Ihr Passwort zurücksetzen wollen.'
|
body: 'Bitte besuchen Sie %{link}, sofern Sie Ihr Passwort zurücksetzen wollen.'
|
||||||
subject: Anweisungen zum Zurücksetzen Ihres Passworts
|
subject: Anweisungen zum Zurücksetzen Ihres Passworts
|
||||||
|
send_thank_you_note:
|
||||||
|
body: |
|
||||||
|
English version below <br>
|
||||||
|
_________________________<br>
|
||||||
|
<br>
|
||||||
|
Hallo %{receiver_displayname}, <br>
|
||||||
|
<br>
|
||||||
|
%{author} hat Ihnen für Ihren Kommentar auf CodeOcean gedankt. <br>
|
||||||
|
<br>
|
||||||
|
%{author} schreibt: %{thank_you_note}<br>
|
||||||
|
<br>
|
||||||
|
Sie finden die Kommentaranfrage hier: %{link_to_comment} <br>
|
||||||
|
<br>
|
||||||
|
Falls Sie beim Klick auf diesen Link eine Fehlermeldung erhalten, dass Sie nicht berechtigt wären diese Aktion auszuführen, öffnen Sie bitte eine beliebige Programmieraufgabe aus einem Kurs heraus und klicken den Link danach noch einmal.<br>
|
||||||
|
<br>
|
||||||
|
Danke, dass Sie anderen Nutzern von CodeOcean helfen!
|
||||||
|
<br>
|
||||||
|
Diese Mail wurde automatisch von CodeOcean verschickt.<br>
|
||||||
|
<br>
|
||||||
|
_________________________<br>
|
||||||
|
<br>
|
||||||
|
Dear %{receiver_displayname}, <br>
|
||||||
|
<br>
|
||||||
|
%{author} thanks you for your comment. <br>
|
||||||
|
<br>
|
||||||
|
%{author} wrote: %{thank_you_note} <br>
|
||||||
|
<br>
|
||||||
|
You can find the request for comments here: %{link_to_comment} <br>
|
||||||
|
<br>
|
||||||
|
If you receive an error that you are not authorized to perform this action when clicking the link, please log-in through any course exercise beforehand and click the link again. <br>
|
||||||
|
<br>
|
||||||
|
Thank you for helping other users on CodeOcean!
|
||||||
|
<br>
|
||||||
|
This mail was automatically sent by CodeOcean. <br>
|
||||||
|
subject: "%{author} sagt danke!"
|
||||||
request_for_comments:
|
request_for_comments:
|
||||||
click_here: Zum Kommentieren auf die Seitenleiste klicken!
|
click_here: Zum Kommentieren auf die Seitenleiste klicken!
|
||||||
comments: Kommentare
|
comments: Kommentare
|
||||||
|
@ -431,6 +431,41 @@ en:
|
|||||||
reset_password:
|
reset_password:
|
||||||
body: 'Please visit %{link} if you want to reset your password.'
|
body: 'Please visit %{link} if you want to reset your password.'
|
||||||
subject: Password reset instructions
|
subject: Password reset instructions
|
||||||
|
send_thank_you_note:
|
||||||
|
body: |
|
||||||
|
English version below <br>
|
||||||
|
_________________________<br>
|
||||||
|
<br>
|
||||||
|
Hallo %{receiver_displayname}, <br>
|
||||||
|
<br>
|
||||||
|
%{author} hat Ihnen für Ihren Kommentar auf CodeOcean gedankt. <br>
|
||||||
|
<br>
|
||||||
|
%{author} schreibt: %{thank_you_note}<br>
|
||||||
|
<br>
|
||||||
|
Sie finden die Kommentaranfrage hier: %{link_to_comment} <br>
|
||||||
|
<br>
|
||||||
|
Falls Sie beim Klick auf diesen Link eine Fehlermeldung erhalten, dass Sie nicht berechtigt wären diese Aktion auszuführen, öffnen Sie bitte eine beliebige Programmieraufgabe aus einem Kurs heraus und klicken den Link danach noch einmal.<br>
|
||||||
|
<br>
|
||||||
|
Danke, dass Sie anderen Nutzern von CodeOcean helfen!
|
||||||
|
<br>
|
||||||
|
Diese Mail wurde automatisch von CodeOcean verschickt.<br>
|
||||||
|
<br>
|
||||||
|
_________________________<br>
|
||||||
|
<br>
|
||||||
|
Dear %{receiver_displayname}, <br>
|
||||||
|
<br>
|
||||||
|
%{author} thanks you for your comment. <br>
|
||||||
|
<br>
|
||||||
|
%{author} wrote: %{thank_you_note} <br>
|
||||||
|
<br>
|
||||||
|
You can find the request for comments here: %{link_to_comment} <br>
|
||||||
|
<br>
|
||||||
|
If you receive an error that you are not authorized to perform this action when clicking the link, please log-in through any course exercise beforehand and click the link again. <br>
|
||||||
|
<br>
|
||||||
|
Thank you for helping other users on CodeOcean!
|
||||||
|
<br>
|
||||||
|
This mail was automatically sent by CodeOcean. <br>
|
||||||
|
subject: "%{author} says thank you!"
|
||||||
request_for_comments:
|
request_for_comments:
|
||||||
click_here: Click on this sidebar to comment!
|
click_here: Click on this sidebar to comment!
|
||||||
comments: Comments
|
comments: Comments
|
||||||
|
Reference in New Issue
Block a user