First working version of mails on comments.
This commit is contained in:
@ -46,7 +46,11 @@ class CommentsController < ApplicationController
|
|||||||
# POST /comments
|
# POST /comments
|
||||||
# POST /comments.json
|
# POST /comments.json
|
||||||
def create
|
def create
|
||||||
@comment = Comment.new(comment_params)
|
@comment = Comment.new(comment_params_without_request_id)
|
||||||
|
|
||||||
|
if comment_params[:request_id]
|
||||||
|
UserMailer.got_new_comment(@comment, RequestForComment.find(comment_params[:request_id]), current_user)
|
||||||
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @comment.save
|
if @comment.save
|
||||||
@ -64,7 +68,7 @@ class CommentsController < ApplicationController
|
|||||||
# PATCH/PUT /comments/1.json
|
# PATCH/PUT /comments/1.json
|
||||||
def update
|
def update
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @comment.update(comment_params)
|
if @comment.update(comment_params_without_request_id)
|
||||||
format.html { head :no_content, notice: 'Comment was successfully updated.' }
|
format.html { head :no_content, notice: 'Comment was successfully updated.' }
|
||||||
format.json { render :show, status: :ok, location: @comment }
|
format.json { render :show, status: :ok, location: @comment }
|
||||||
else
|
else
|
||||||
@ -101,10 +105,14 @@ class CommentsController < ApplicationController
|
|||||||
@comment = Comment.find(params[:id])
|
@comment = Comment.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def comment_params_without_request_id
|
||||||
|
comment_params.except :request_id
|
||||||
|
end
|
||||||
|
|
||||||
# Never trust parameters from the scary internet, only allow the white list through.
|
# Never trust parameters from the scary internet, only allow the white list through.
|
||||||
def comment_params
|
def comment_params
|
||||||
#params.require(:comment).permit(:user_id, :file_id, :row, :column, :text)
|
#params.require(:comment).permit(:user_id, :file_id, :row, :column, :text)
|
||||||
# fuer production mode, damit böse menschen keine falsche user_id uebergeben:
|
# fuer production mode, damit böse menschen keine falsche user_id uebergeben:
|
||||||
params.require(:comment).permit(:file_id, :row, :column, :text).merge(user_id: current_user.id, user_type: current_user.class.name)
|
params.require(:comment).permit(:file_id, :row, :column, :text, :request_id).merge(user_id: current_user.id, user_type: current_user.class.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -12,8 +12,12 @@ class UserMailer < ActionMailer::Base
|
|||||||
mail(subject: t('mailers.user_mailer.reset_password.subject'), to: user.email)
|
mail(subject: t('mailers.user_mailer.reset_password.subject'), to: user.email)
|
||||||
end
|
end
|
||||||
|
|
||||||
def got_new_comment(comment, user, commenting_user)
|
def got_new_comment(comment, request_for_comment, commenting_user)
|
||||||
@commenting_user = commenting_user
|
# todo: check whether we can take the last known locale of the receiver?
|
||||||
mail(subject: t('mailers.user_mailer.got_new_comment.subject'), to: user.email)
|
@receiver_displayname = request_for_comment.user.displayname
|
||||||
|
@commenting_user_displayname = commenting_user.displayname
|
||||||
|
@comment_text = comment.text
|
||||||
|
@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).deliver
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
<h4 class="list-group-item-heading"><%= Exercise.find(@request_for_comment.exercise_id) %></h4>
|
<h4 class="list-group-item-heading" data-rfc-id = "<%= @request_for_comment.id %>" ><%= Exercise.find(@request_for_comment.exercise_id) %></h4>
|
||||||
<p class="list-group-item-text">
|
<p class="list-group-item-text">
|
||||||
<%
|
<%
|
||||||
user = @request_for_comment.user
|
user = @request_for_comment.user
|
||||||
@ -101,7 +101,8 @@ do not put a carriage return in the line below. it will be present in the presen
|
|||||||
file_id: file_id,
|
file_id: file_id,
|
||||||
row: row,
|
row: row,
|
||||||
column: 0,
|
column: 0,
|
||||||
text: commenttext
|
text: commenttext,
|
||||||
|
request_id: $('h4').data('rfc-id')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
@ -1 +1 @@
|
|||||||
== t('mailers.user_mailer.activation_needed.body', link: link_to(@activation_url, @activation_url))
|
== t('mailers.user_mailer.got_new_comment.body', receiver_displayname: @receiver_displayname, link: link_to(@rfc_link, @rfc_link), commenting_user_displayname: @commenting_user_displayname, comment_text: @comment_text)
|
||||||
|
@ -325,6 +325,13 @@ de:
|
|||||||
activation_needed:
|
activation_needed:
|
||||||
body: 'Bitte besuchen Sie %{link} und wählen Sie ein Passwort, um Ihre Registrierung abzuschließen.'
|
body: 'Bitte besuchen Sie %{link} und wählen Sie ein Passwort, um Ihre Registrierung abzuschließen.'
|
||||||
subject: Bitte schließen Sie Ihre Registrierung ab.
|
subject: Bitte schließen Sie Ihre Registrierung ab.
|
||||||
|
got_new_comment:
|
||||||
|
body: |
|
||||||
|
Hallo %{receiver_displayname},
|
||||||
|
|
||||||
|
es gibt einen neuen Kommentar von %{commenting_user_displayname} zu Ihrer Kommentaranfrage auf CodeOcean.
|
||||||
|
Sie finden ihn hier: %{link}
|
||||||
|
subject: Sie haben einen neuen Kommentar von %{commenting_user_displayname} auf CodeOcean erhalten.
|
||||||
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
|
||||||
|
@ -325,6 +325,16 @@ en:
|
|||||||
activation_needed:
|
activation_needed:
|
||||||
body: 'Please visit %{link} and set up a password in order to complete your registration.'
|
body: 'Please visit %{link} and set up a password in order to complete your registration.'
|
||||||
subject: Please complete your registration.
|
subject: Please complete your registration.
|
||||||
|
got_new_comment:
|
||||||
|
body: |
|
||||||
|
Dear %{receiver_displayname},
|
||||||
|
|
||||||
|
you received a new comment from %{commenting_user_displayname} to your request for comments on CodeOcean.
|
||||||
|
You can find it here: %{link}
|
||||||
|
|
||||||
|
Best regards,
|
||||||
|
your Teaching Team
|
||||||
|
subject: 'You received a new comment on CodeOcean from %{commenting_user_displayname}.'
|
||||||
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
|
||||||
|
Reference in New Issue
Block a user