-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #370 from alphagov/add-petition-emails
Add petition emails
- Loading branch information
Showing
53 changed files
with
1,062 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
class Admin::PetitionEmailsController < Admin::AdminController | ||
respond_to :html | ||
before_action :fetch_petition | ||
before_action :build_email | ||
|
||
def new | ||
render 'admin/petitions/show' | ||
end | ||
|
||
def create | ||
if @email.update(email_params) | ||
EmailPetitionersJob.run_later_tonight(petition: @petition, email: @email) | ||
PetitionMailer.email_signer(@petition, feedback_signature, @email).deliver_now | ||
|
||
redirect_to [:admin, @petition], notice: 'Email will be sent overnight' | ||
else | ||
render 'admin/petitions/show' | ||
end | ||
end | ||
|
||
private | ||
|
||
def fetch_petition | ||
@petition = Petition.moderated.find(params[:petition_id]) | ||
end | ||
|
||
def build_email | ||
@email = @petition.emails.build(sent_by: current_user.pretty_name) | ||
end | ||
|
||
def email_params | ||
params.require(:petition_email).permit(:subject, :body) | ||
end | ||
|
||
def feedback_signature | ||
FeedbackSignature.new(@petition) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class DeliverPetitionEmailJob < ActiveJob::Base | ||
include EmailDelivery | ||
|
||
attr_reader :email | ||
|
||
def perform(**args) | ||
@email = args[:email] | ||
super | ||
end | ||
|
||
def create_email | ||
mailer.email_signer petition, signature, email | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
class EmailDebateOutcomesJob < ActiveJob::Base | ||
include EmailAllPetitionSignatories | ||
|
||
def email_delivery_job_class | ||
DeliverDebateOutcomeEmailJob | ||
end | ||
|
||
def timestamp_name | ||
'debate_outcome' | ||
end | ||
self.email_delivery_job_class = DeliverDebateOutcomeEmailJob | ||
self.timestamp_name = 'debate_outcome' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
class EmailDebateScheduledJob < ActiveJob::Base | ||
include EmailAllPetitionSignatories | ||
|
||
def email_delivery_job_class | ||
DeliverDebateScheduledEmailJob | ||
end | ||
|
||
def timestamp_name | ||
'debate_scheduled' | ||
end | ||
self.email_delivery_job_class = DeliverDebateScheduledEmailJob | ||
self.timestamp_name = 'debate_scheduled' | ||
end |
Oops, something went wrong.