|
|
|
2 class PetitionMailer < ApplicationMailer
|
|
3 include ActiveSupport::NumberHelper
|
|
|
|
5 def email_signer(petition, signature, email)
|
|
6 @petition, @signature, @email = petition, signature, email
|
|
|
|
8 mail to: @signature.email,
|
|
9 subject: subject_for(:email_signer),
|
|
10 list_unsubscribe: unsubscribe_url
|
|
|
|
|
|
13 def email_creator(petition, signature, email)
|
|
14 @petition, @signature, @email = petition, signature, email
|
|
15 mail to: @signature.email,
|
|
16 subject: subject_for(:email_creator),
|
|
17 list_unsubscribe: unsubscribe_url
|
|
|
|
|
|
20 def notify_signer_of_threshold_response(petition, signature)
|
|
21 @petition, @signature = petition, signature
|
|
22 @government_response, @parliament = petition.government_response, petition.parliament
|
|
|
|
24 mail to: @signature.email,
|
|
25 subject: subject_for(:notify_signer_of_threshold_response),
|
|
26 list_unsubscribe: unsubscribe_url
|
|
|
|
|
|
29 def notify_creator_of_threshold_response(petition, signature)
|
|
30 @petition, @signature = petition, signature
|
|
31 @government_response, @parliament = petition.government_response, petition.parliament
|
|
|
|
33 mail to: @signature.email,
|
|
34 subject: subject_for(:notify_creator_of_threshold_response),
|
|
35 list_unsubscribe: unsubscribe_url
|
|
|
|
|
|
38 def notify_signer_of_debate_scheduled(petition, signature)
|
|
39 @petition, @signature = petition, signature
|
|
|
|
41 mail to: @signature.email,
|
|
42 subject: subject_for(:notify_signer_of_debate_scheduled),
|
|
43 list_unsubscribe: unsubscribe_url
|
|
|
|
|
|
46 def notify_creator_of_debate_scheduled(petition, signature)
|
|
47 @petition, @signature = petition, signature
|
|
48 mail to: @signature.email,
|
|
49 subject: subject_for(:notify_creator_of_debate_scheduled),
|
|
50 list_unsubscribe: unsubscribe_url
|
|
|
|
|
|
53 def notify_signer_of_debate_outcome(petition, signature)
|
|
54 @petition, @debate_outcome, @signature = petition, petition.debate_outcome, signature
|
|
|
|
56 if @debate_outcome.debated?
|
|
57 subject = subject_for(:notify_signer_of_positive_debate_outcome)
|
|
|
|
59 subject = subject_for(:notify_signer_of_negative_debate_outcome)
|
|
|
|
|
|
62 mail to: @signature.email, subject: subject, list_unsubscribe: unsubscribe_url
|
|
|
|
|
|
65 def notify_creator_of_debate_outcome(petition, signature)
|
|
66 @petition, @debate_outcome, @signature = petition, petition.debate_outcome, signature
|
|
|
|
68 if @debate_outcome.debated?
|
|
69 subject = subject_for(:notify_creator_of_positive_debate_outcome)
|
|
|
|
71 subject = subject_for(:notify_creator_of_negative_debate_outcome)
|
|
|
|
|
|
74 mail to: @signature.email, subject: subject, list_unsubscribe: unsubscribe_url
|
|
|
|
|
|
|
|
|
|
79 def subject_for(key, options = {})
|
|
80 I18n.t key, i18n_options.merge(options)
|
|
|
|
|
|
83 def signature_belongs_to_creator?
|
|
84 @signature && @signature.creator?
|
|
|
|
|
- DuplicateMethodCall - calls '@petition.signature_count' 2 times » reek
- TooManyStatements - has approx 6 statements » reek
- Complexity 4 » saikuro
|
|
|
|
|
89 options[:scope] = :"petitions.emails.subjects"
|
|
|
|
91 if defined?(@petition)
|
|
92 options[:count] = @petition.signature_count
|
|
93 options[:formatted_count] = number_to_delimited(@petition.signature_count)
|
|
94 options[:action] = @petition.action
|
|
|
|
|
|
|
|
98 options[:subject] = @email.subject
|
|
|
|
|
|
|
|
|
|
|
|
104 "<#{unsubscribe_archived_signature_url(@signature, token: @signature.unsubscribe_token)}>"
|
|
|
|
|
|
|