Translations and preview for organisation moderation mails

rails5
echarp 6 years ago
parent 367fb9bf91
commit 2a4e71f7a9
  1. 13
      app/mailers/event_mailer.rb
  2. 19
      app/mailers/moderation_mailer.rb
  3. 39
      app/mailers/moderationorga_mailer.rb
  4. 13
      app/mailers/note_mailer.rb
  5. 39
      app/mailers/orga_mailer.rb
  6. 4
      app/views/moderationorga_mailer/destroy.text.haml
  7. 4
      config/locales/views/en.yml
  8. 5
      config/locales/views/fr.yml
  9. 3
      test/controllers/orgas_controller_test.rb
  10. 6
      test/fixtures/orgas.yml
  11. 34
      test/mailers/previews/moderationorga_mailer_preview.rb
  12. 1
      test/mailers/previews/orga_mailer_preview.rb
  13. 6
      test/models/orga_test.rb

@ -8,8 +8,7 @@ class EventMailer < ApplicationMailer
mail 'Message-ID' =>
"<event-#{event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
to: event.submitter,
subject: "#{t 'mail_prefix'}#{t 'event_mailer.create.subject',
subject: event.title}"
subject: subject(event)
end
# Send email to submitter too. Before, only moderators were receiving emails
@ -21,8 +20,7 @@ class EventMailer < ApplicationMailer
mail 'In-Reply-To' =>
"<event-#{event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
to: event.submitter,
subject: "#{t 'mail_prefix'}#{t 'event_mailer.update.subject',
subject: event.title}"
subject: subject(event)
end
def accept(event)
@ -46,4 +44,11 @@ class EventMailer < ApplicationMailer
subject: "#{t 'mail_prefix'}#{t 'event_mailer.destroy.subject',
subject: event.title}"
end
private
def subject(event)
t('mail_prefix') +
t("#{mailer_name}.#{action_name}.subject", subject: event.title)
end
end

@ -7,8 +7,7 @@ class ModerationMailer < ApplicationMailer
mail 'Message-ID' =>
"<mod-#{event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
subject: "#{t 'mail_prefix'}#{t 'moderation_mailer.create.subject',
subject: event.title}"
subject: subject(event)
end
def update(event)
@ -17,8 +16,7 @@ class ModerationMailer < ApplicationMailer
mail 'In-Reply-To' =>
"<mod-#{event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
subject: "#{t 'mail_prefix'}#{t 'moderation_mailer.update.subject',
subject: event.title}"
subject: subject(event)
end
def accept(event)
@ -27,8 +25,7 @@ class ModerationMailer < ApplicationMailer
mail 'In-Reply-To' =>
"<mod-#{event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
subject: "#{t 'mail_prefix'}#{t 'moderation_mailer.accept.subject',
subject: event.title}"
subject: subject(event)
end
def destroy(event)
@ -37,7 +34,13 @@ class ModerationMailer < ApplicationMailer
mail 'In-Reply-To' =>
"<mod-#{event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
subject: "#{t 'mail_prefix'}#{t 'moderation_mailer.destroy.subject',
subject: event.title}"
subject: subject(event)
end
private
def subject(event)
t('mail_prefix') +
t("#{mailer_name}.#{action_name}.subject", subject: event.title)
end
end

@ -2,55 +2,32 @@
class ModerationorgaMailer < ApplicationMailer
helper :events
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.orga_mailer.create.subject
#
def create(orga)
@orga = orga
mail 'Message-ID' =>
"<orga-#{orga.id}@#{ActionMailer::Base.default_url_options[:host]}>",
subject: "#{t 'mail_prefix'}#{t 'moderationorga_mailer.create.subject',
subject: orga.name}"
subject: subject(orga)
end
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.orga_mailer.update.subject
#
def update(orga)
@orga = orga
@current_user = User.find_by id: orga.paper_trail.originator
mail 'In-Reply-To' =>
"<orga-#{orga.id}@#{ActionMailer::Base.default_url_options[:host]}>",
subject: "#{t 'mail_prefix'}#{t 'moderationorga_mailer.update.subject',
subject: orga.name}"
subject: subject(orga)
end
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.orga_mailer.accept.subject
#
def accept(orga)
@orga = orga
@current_user = User.find_by id: orga.paper_trail.originator
mail 'In-Reply-To' =>
"<orga-#{orga.id}@#{ActionMailer::Base.default_url_options[:host]}>",
subject: "#{t 'mail_prefix'}#{t 'moderationorga_mailer.accept.subject',
subject: orga.name}"
subject: subject(orga)
end
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.orga_mailer.destroy.subject
#
def destroy(orga, reason = '')
@orga = orga
@current_user = User.find_by id: orga.paper_trail.originator
@ -58,7 +35,13 @@ class ModerationorgaMailer < ApplicationMailer
mail 'In-Reply-To' =>
"<orga-#{orga.id}@#{ActionMailer::Base.default_url_options[:host]}>",
subject: t('mail_prefix') + t('moderationorga_mailer.destroy.subject',
subject: orga.name)
subject: subject(orga)
end
private
def subject(orga)
t('mail_prefix') +
t("#{mailer_name}.#{action_name}.subject", subject: orga.name)
end
end

@ -9,8 +9,7 @@ class NoteMailer < ApplicationMailer
mail 'In-Reply-To' =>
"<event-#{note.event.id}@#{host}>",
to: note.event.submitter,
subject: "#{t 'mail_prefix'}#{t 'note_mailer.notify.subject',
subject: note.event.title}"
subject: subject(note.event)
end
def create(note)
@ -18,7 +17,13 @@ class NoteMailer < ApplicationMailer
mail 'In-Reply-To' =>
"<mod-#{note.event.id}@#{ActionMailer::Base.default_url_options[:host]}>",
subject: "#{t 'mail_prefix'}#{t 'note_mailer.create.subject',
subject: note.event.title}"
subject: subject(note.event)
end
private
def subject(event)
t('mail_prefix') +
t("#{mailer_name}.#{action_name}.subject", subject: event.title)
end
end

@ -2,26 +2,15 @@
class OrgaMailer < ApplicationMailer
helper :events
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.orga_mailer.create.subject
#
def create(orga)
@orga = orga
mail 'Message-ID' =>
"<orga-#{orga.id}@#{ActionMailer::Base.default_url_options[:host]}>",
to: orga.submitter,
subject: "#{t 'mail_prefix'}#{t 'orga_mailer.create.subject',
subject: orga.name}"
subject: subject(orga)
end
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.orga_mailer.update.subject
#
def update(orga)
@orga = orga
@current_user = User.find_by id: orga.paper_trail.originator
@ -29,15 +18,9 @@ class OrgaMailer < ApplicationMailer
mail 'Message-ID' =>
"<orga-#{orga.id}@#{ActionMailer::Base.default_url_options[:host]}>",
to: orga.submitter,
subject: "#{t 'mail_prefix'}#{t 'orga_mailer.update.subject',
subject: orga.name}"
subject: subject(orga)
end
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.orga_mailer.accept.subject
#
def accept(orga)
@orga = orga
@current_user = User.find_by id: orga.paper_trail.originator
@ -45,15 +28,9 @@ class OrgaMailer < ApplicationMailer
mail 'In-Reply-To' =>
"<orga-#{orga.id}@#{ActionMailer::Base.default_url_options[:host]}>",
to: orga.submitter,
subject: "#{t 'mail_prefix'}#{t 'orga_mailer.accept.subject',
subject: orga.name}"
subject: subject(orga)
end
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.orga_mailer.destroy.subject
#
def destroy(orga, reason = '')
@orga = orga
@current_user = User.find_by id: orga.paper_trail.originator
@ -62,7 +39,13 @@ class OrgaMailer < ApplicationMailer
mail 'In-Reply-To' =>
"<orga-#{orga.id}@#{ActionMailer::Base.default_url_options[:host]}>",
to: orga.submitter,
subject: "#{t 'mail_prefix'}#{t 'orga_mailer.destroy.subject',
subject: orga.name}"
subject: subject(orga)
end
private
def subject(orga)
t('mail_prefix') +
t("#{mailer_name}.#{action_name}.subject", subject: orga.name)
end
end

@ -1,6 +1,4 @@
= t '.body', author: @current_user
\
= @reason
= t '.body', subject: @orga.name, author: @current_user
\
= t '.reclamation'
\

@ -434,9 +434,7 @@ reason:
destroy:
subject: "Organisation '%{subject}' refused"
body: "Organisation '%{subject}' was rejected by %{author} for the
following reason:
\n
\n"
following reason:"
reminder: "The organisation:"
signature: Thank you for your contribution

@ -436,8 +436,9 @@ pouvez éditer votre événement à l'adresse:"
signature: Merci pour votre contribution!
destroy:
subject: "Organisation '%{subject}' refusée"
body: "L'organisation '%{subject}' a été rejetée par %{author} pour la
raison suivante:"
body: "L'organisation '%{subject}' a été rejetée par %{author}"
reclamation: Pour toute réclamation, n'hésitez pas à contacter l'équipe
de modérateurs.
reminder: "Pour rappel, l'organisation:"
signature: Merci pour votre contribution

@ -30,7 +30,8 @@ class OrgasControllerTest < ActionController::TestCase
url: @orga.url,
feed: @orga.feed,
contact: @orga.contact,
submitter: @orga.contact
submitter: @orga.contact,
tags: @orga.tags
}
assert_empty assigns(:orga).errors.messages

@ -3,25 +3,27 @@
one:
kind: lug
name: MyString
description: MyText
city: Jolie ville
department: 1
region: region_one
url: http://april.org
feed: http://april.org/index.rss
contact: test@exemple.com
submitter: test@exemple.com
submission_time: 2013-12-28 16:04:56
tags: my-string
secret: my_secret
moderated: true
two:
kind: provider
name: MyString
description: MyText
city: Jolie ville
department: 1
region: region_two
url: http://april.org
feed: http://april.org/index.rss
contact: test@exemple.com
submitter: test@exemple.com
submission_time: 2013-12-28 16:04:56
tags: my-string

@ -0,0 +1,34 @@
# Preview all emails at http://localhost:3000/rails/mailers/moderationorga_mailer
class ModerationorgaMailerPreview < ActionMailer::Preview
# Preview this email at http://localhost:3000/rails/mailers/moderationorga_mailer/create
def create
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
ModerationorgaMailer.create Orga.last
end
# Preview this email at http://localhost:3000/rails/mailers/moderationorga_mailer/update
def update
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
orga = Orga.first
orga.tags += ' ho'
orga.save!
orga.description = orga.description + '
hello world'
ModerationorgaMailer.update orga
end
# Preview this email at http://localhost:3000/rails/mailers/moderationorga_mailer/accept
def accept
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
ModerationorgaMailer.accept Orga.last
end
# Preview this email at http://localhost:3000/rails/mailers/moderationorga_mailer/destroy
def destroy
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
orga = Orga.last
ModerationorgaMailer.destroy orga
end
end

@ -10,6 +10,7 @@ class OrgaMailerPreview < ActionMailer::Preview
def update
ActionMailer::Base.default_url_options[:host] = 'localhost:3000'
orga = Orga.last
orga.name += ' et hop'
orga.save!
OrgaMailer.update orga

@ -16,7 +16,8 @@ class OrgaTest < ActiveSupport::TestCase
url: 'http://example.com',
region: Region.first,
contact: 'contact@example.com',
submitter: 'contact@example.com'
submitter: 'contact@example.com',
tags: 'hello world'
)
end
@ -26,7 +27,8 @@ class OrgaTest < ActiveSupport::TestCase
name: 'Tested organisation',
url: 'http://example.com',
region: Region.first,
contact: 'contact@example.com'
contact: 'contact@example.com',
tags: 'hello world'
)
end
end

Loading…
Cancel
Save