|
1class PetitionMailer < ApplicationMailer
|
|
2 include ActiveSupport::NumberHelper
|
|
|
|
4 def email_confirmation_for_signer(signature)
|
|
5 @signature, @petition = signature, signature.petition
|
|
6 mail to: @signature.email, subject: subject_for(:email_confirmation_for_signer)
|
|
|
|
|
|
9 def email_duplicate_signatures(signature)
|
|
10 @signature, @petition = signature, signature.petition
|
|
11 mail to: @signature.email, subject: subject_for(:email_duplicate_signatures)
|
|
|
|
|
|
14 def email_signer(petition, signature, email)
|
|
15 @petition, @signature, @email = petition, signature, email
|
|
|
|
17 mail to: @signature.email,
|
|
18 subject: subject_for(:email_signer),
|
|
19 list_unsubscribe: unsubscribe_url
|
|
|
|
|
|
22 def email_creator(petition, signature, email)
|
|
23 @petition, @signature, @email = petition, signature, email
|
|
24 mail to: @signature.email,
|
|
25 subject: subject_for(:email_creator),
|
|
26 list_unsubscribe: unsubscribe_url
|
|
|
|
|
|
29 def special_resend_of_email_confirmation_for_signer(signature)
|
|
30 @signature, @petition = signature, signature.petition
|
|
31 mail to: @signature.email, subject: subject_for(:special_resend_of_email_confirmation_for_signer)
|
|
|
|
|
|
34 def notify_creator_that_petition_is_published(signature)
|
|
35 @signature, @petition = signature, signature.petition
|
|
|
|
37 mail to: @signature.email,
|
|
38 subject: subject_for(:notify_creator_that_petition_is_published),
|
|
39 list_unsubscribe: unsubscribe_url
|
|
|
|
|
|
42 def notify_sponsor_that_petition_is_published(signature)
|
|
43 @signature, @petition = signature, signature.petition
|
|
44 mail to: @signature.email, subject: subject_for(:notify_sponsor_that_petition_is_published)
|
|
|
|
|
- DuplicateMethodCall - calls 'signature.petition' 2 times » reek
- Complexity 1 » saikuro
|
47 def notify_creator_that_petition_was_rejected(signature)
|
|
48 @signature, @petition, @rejection = signature, signature.petition, signature.petition.rejection
|
|
49 mail to: @signature.email, subject: subject_for(:notify_creator_that_petition_was_rejected)
|
|
|
|
|
- DuplicateMethodCall - calls 'signature.petition' 2 times » reek
- Complexity 1 » saikuro
|
52 def notify_sponsor_that_petition_was_rejected(signature)
|
|
53 @signature, @petition, @rejection = signature, signature.petition, signature.petition.rejection
|
|
54 mail to: @signature.email, subject: subject_for(:notify_sponsor_that_petition_was_rejected)
|
|
|
|
|
|
57 def notify_signer_of_threshold_response(petition, signature)
|
|
58 @petition, @signature, @government_response = petition, signature, petition.government_response
|
|
|
|
60 mail to: @signature.email,
|
|
61 subject: subject_for(:notify_signer_of_threshold_response),
|
|
62 list_unsubscribe: unsubscribe_url
|
|
|
|
|
|
65 def notify_creator_of_threshold_response(petition, signature)
|
|
66 @petition, @signature, @government_response = petition, signature, petition.government_response
|
|
|
|
68 mail to: @signature.email,
|
|
69 subject: subject_for(:notify_creator_of_threshold_response),
|
|
70 list_unsubscribe: unsubscribe_url
|
|
|
|
|
|
73 def notify_creator_of_closing_date_change(signature, dissolution_at = Parliament.dissolution_at)
|
|
74 @signature, @petition = signature, signature.petition
|
|
|
|
76 @closing_time = dissolution_at.strftime('%H:%M%P')
|
|
77 @closing_date = dissolution_at.strftime('%-d %B')
|
|
78 @last_response_date = dissolution_at.yesterday.strftime('%-d %B')
|
|
|
|
80 mail to: @signature.email, subject: subject_for(:notify_creator_of_closing_date_change)
|
|
|
|
|
|
83 def notify_creator_of_sponsored_petition_being_stopped(signature)
|
|
84 @signature, @petition = signature, signature.petition
|
|
85 mail to: @signature.email, subject: subject_for(:notify_creator_of_sponsored_petition_being_stopped)
|
|
|
|
|
|
88 def notify_creator_of_validated_petition_being_stopped(signature)
|
|
89 @signature, @petition = signature, signature.petition
|
|
90 mail to: @signature.email, subject: subject_for(:notify_creator_of_validated_petition_being_stopped)
|
|
|
|
|
|
93 def gather_sponsors_for_petition(petition, bcc = nil)
|
|
94 @petition, @creator = petition, petition.creator
|
|
95 mail to: @creator.email, bcc: bcc, subject: subject_for(:gather_sponsors_for_petition)
|
|
|
|
|
|
98 def notify_signer_of_debate_outcome(petition, signature)
|
|
99 @petition, @debate_outcome, @signature = petition, petition.debate_outcome, signature
|
|
|
|
101 if @debate_outcome.debated?
|
|
102 subject = subject_for(:notify_signer_of_positive_debate_outcome)
|
|
|
|
104 subject = subject_for(:notify_signer_of_negative_debate_outcome)
|
|
|
|
|
|
107 mail to: @signature.email, subject: subject, list_unsubscribe: unsubscribe_url
|
|
|
|
|
|
110 def notify_creator_of_debate_outcome(petition, signature)
|
|
111 @petition, @debate_outcome, @signature = petition, petition.debate_outcome, signature
|
|
|
|
113 if @debate_outcome.debated?
|
|
114 subject = subject_for(:notify_creator_of_positive_debate_outcome)
|
|
|
|
116 subject = subject_for(:notify_creator_of_negative_debate_outcome)
|
|
|
|
|
|
119 mail to: @signature.email, subject: subject, list_unsubscribe: unsubscribe_url
|
|
|
|
|
|
122 def notify_signer_of_debate_scheduled(petition, signature)
|
|
123 @petition, @signature = petition, signature
|
|
|
|
125 mail to: @signature.email,
|
|
126 subject: subject_for(:notify_signer_of_debate_scheduled),
|
|
127 list_unsubscribe: unsubscribe_url
|
|
|
|
|
|
130 def notify_creator_of_debate_scheduled(petition, signature)
|
|
131 @petition, @signature = petition, signature
|
|
132 mail to: @signature.email,
|
|
133 subject: subject_for(:notify_creator_of_debate_scheduled),
|
|
134 list_unsubscribe: unsubscribe_url
|
|
|
|
|
|
137 def notify_creator_that_moderation_is_delayed(signature, subject, body)
|
|
138 @petition, @signature = signature.petition, signature
|
|
139 @subject, @body = subject, body
|
|
|
|
141 mail to: @signature.email,
|
|
142 subject: subject_for(:notify_creator_that_moderation_is_delayed),
|
|
143 list_unsubscribe: unsubscribe_url
|
|
|
|
|
|
|
|
|
|
148 def subject_for(key, options = {})
|
|
149 I18n.t key, i18n_options.merge(options)
|
|
|
|
|
|
152 def signature_belongs_to_creator?
|
|
153 @signature && @signature.creator?
|
|
|
|
|
- DuplicateMethodCall - calls '@petition.signature_count' 2 times » reek
- TooManyStatements - has approx 7 statements » reek
- Complexity 5 » saikuro
|
|
|
|
|
158 options[:scope] = :"petitions.emails.subjects"
|
|
|
|
160 if defined?(@petition)
|
|
161 options[:count] = @petition.signature_count
|
|
162 options[:formatted_count] = number_to_delimited(@petition.signature_count)
|
|
163 options[:action] = @petition.action
|
|
|
|
|
|
|
|
167 options[:subject] = @email.subject
|
|
|
|
|
|
170 if defined?(@subject)
|
|
171 options[:subject] = @subject
|
|
|
|
|
|
|
|
|
|
|
|
177 "<#{unsubscribe_signature_url(@signature, token: @signature.unsubscribe_token)}>"
|
|
|
|
|