Class: Decidim::Initiatives::InitiativesMailer

Inherits:
ApplicationMailer
  • Object
show all
Includes:
SanitizeHelper, TranslatableAttributes
Defined in:
app/mailers/decidim/initiatives/initiatives_mailer.rb

Overview

Mailer for initiatives engine.

Instance Method Summary collapse

Instance Method Details

#notify_creation(initiative) ⇒ Object

Notifies initiative creation



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/mailers/decidim/initiatives/initiatives_mailer.rb', line 14

def notify_creation(initiative)
  return if initiative.author.email.blank?

  @initiative = initiative
  @organization = initiative.organization

  with_user(initiative.author) do
    @subject = I18n.t(
      "decidim.initiatives.initiatives_mailer.creation_subject",
      title: translated_attribute(initiative.title)
    )

    mail(to: "#{initiative.author.name} <#{initiative.author.email}>", subject: @subject)
  end
end

#notify_progress(initiative, user) ⇒ Object

Notify progress to all initiative subscribers.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/mailers/decidim/initiatives/initiatives_mailer.rb', line 55

def notify_progress(initiative, user)
  return if user.email.blank?

  @organization = initiative.organization
  @link = initiative_url(initiative, host: @organization.host)

  with_user(user) do
    @body = I18n.t(
      "decidim.initiatives.initiatives_mailer.progress_report_body_for",
      title: translated_attribute(initiative.title),
      percentage: initiative.percentage
    )

    @subject = I18n.t(
      "decidim.initiatives.initiatives_mailer.progress_report_for",
      title: translated_attribute(initiative.title)
    )

    mail(to: "#{user.name} <#{user.email}>", subject: @subject)
  end
end

#notify_state_change(initiative, user) ⇒ Object

Notify changes in state



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/mailers/decidim/initiatives/initiatives_mailer.rb', line 31

def notify_state_change(initiative, user)
  return if user.email.blank?

  @organization = initiative.organization

  with_user(user) do
    @subject = I18n.t(
      "decidim.initiatives.initiatives_mailer.status_change_for",
      title: translated_attribute(initiative.title)
    )

    @body = I18n.t(
      "decidim.initiatives.initiatives_mailer.status_change_body_for",
      title: translated_attribute(initiative.title),
      state: I18n.t(initiative.state, scope: "decidim.initiatives.admin_states")
    )

    @link = initiative_url(initiative, host: @organization.host)

    mail(to: "#{user.name} <#{user.email}>", subject: @subject)
  end
end