Le rajout de note à un evt en modération génère un mail à destination des modérateurs

This commit is contained in:
echarp 2014-07-21 01:26:58 +02:00
parent 4ba60cbcbc
commit 2cacc6b444
7 changed files with 48 additions and 14 deletions

View File

@ -15,10 +15,11 @@ class NotesController < ApplicationController
if @note.save
if params[:envoiParMail] == 'oui'
# Send an update mail to its author
NoteMailer.create(@note).deliver
NoteMailer.notify(@note).deliver
@note.contents = t '.sendByMailWrap', contents: @note.contents
@note.save
end
NoteMailer.create(@note).deliver
format.html { redirect_to moderations_url, notice: t('.ok') }
format.json { render action: 'show', status: :created, location: @event }

View File

@ -1,10 +1,16 @@
class NoteMailer < ActionMailer::Base
def create(note)
def notify(note)
@note = note
mail 'In-Reply-To' => "<event-#{note.event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
to: note.event.submitter,
cc: AgendaDuLibreRails::Application.config.action_mailer.default_options[:from],
subject: t('note_mailer.notify.subject', subject: note.event.title)
end
def create(note)
@note = note
mail 'In-Reply-To' => "<mod-#{note.event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
subject: t('note_mailer.create.subject', subject: note.event.title)
end
end

View File

@ -2,12 +2,8 @@
\
=t '.body', subject: @note.event.title, contents: @note.contents
\
= sanitize @note.contents.html_safe,
tags: %w(p br table tr td ul ol li a strong b em i img),
attributes: %w(href src width height)
= strip_tags @note.contents
\
= moderations_url
\
=t '.edit_link'
\
= edit_event_url @note.event, secret: @note.event.secret
\
=t '.signature'

View File

@ -0,0 +1,13 @@
=t '.title'
\
=t '.body', subject: @note.event.title, contents: @note.contents
\
= sanitize @note.contents.html_safe,
tags: %w(p br table tr td ul ol li a strong b em i img),
attributes: %w(href src width height)
\
=t '.edit_link'
\
= edit_event_url @note.event, secret: @note.event.secret
\
=t '.signature'

View File

@ -229,7 +229,7 @@ Exemple: `%{daylimit}`"
back: Modération
title: Ajout d'une note de modération
create:
sendByMailWrap: "<p>Demande d'informations complémentaires:</p><pre>%{contents}</pre>"
sendByMailWrap: "<p>Demande d'informations complémentaires:</p> <pre>%{contents}</pre>"
ok: La note a bien été ajoutée, merci!
form:
title: Rédaction du message
@ -298,7 +298,7 @@ Exemple: `%{daylimit}`"
reminder: "Pour rappel, l'événement:"
signature: "-- \nL'équipe des modérateurs de l'Agenda du Libre"
note_mailer:
create:
notify:
subject: "[Agenda du Libre] Demande d'informations sur l'événement '%{subject}'"
title: Bonjour,
body: "Nous avons bien reçu votre proposition d'événement '%{subject}',
@ -308,3 +308,8 @@ Exemple: `%{daylimit}`"
edit_link: "Nous vous invitons à ajouter ces informations en éditant directement
\nl'événement à l'adresse suivante:"
signature: "Avec tous nos remerciements pour votre contribution,\n\n-- \nL'équipe des modérateurs de l'Agenda du Libre"
create:
subject: "[Agenda du Libre] Une note a été rajoutée à l'événement '%{subject}'"
title: Bonjour,
body: "Une note a été rajoutée à '%{subject}':"
signature: "-- \nL'équipe de modération"

View File

@ -5,10 +5,17 @@ class NoteMailerTest < ActionMailer::TestCase
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
end
test 'create' do
mail = NoteMailer.create Note.last
test 'notify' do
mail = NoteMailer.notify Note.last
assert_match(/\[Agenda du Libre\] Demande d'informations sur l'événement .*/, mail.subject)
assert_equal [Note.last.event.contact], mail.to
assert_equal ["moderateurs@agendadulibre.org"], mail.from
end
test 'create' do
mail = NoteMailer.create Note.last
assert_match(/\[Agenda du Libre\] Une note a été rajoutée à l'événement .*/, mail.subject)
assert_not_equal [Note.last.event.contact], mail.to
assert_equal ["moderateurs@agendadulibre.org"], mail.from
end
end

View File

@ -1,5 +1,11 @@
# Preview all emails at http://localhost:3000/rails/mailers/note_mailer
class NoteMailerPreview < ActionMailer::Preview
# Preview this email at http://localhost:3000/rails/mailers/note_mailer/notify
def notify
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
NoteMailer.notify Note.last
end
# Preview this email at http://localhost:3000/rails/mailers/note_mailer/create
def create
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'