From 1854c6c44c9bfb3202b3d2c74ec2f5ead8bc287c Mon Sep 17 00:00:00 2001 From: Emily <44536222+emi-hi@users.noreply.github.com> Date: Thu, 14 Apr 2022 11:41:39 -0700 Subject: [PATCH] -renames household form, removes leading space (#73) -updates household form import in index -adds spouse initial email to signals, restructures email function to accept more arguments --- django/api/signals.py | 61 ++++++++++++++----- .../{ HouseholdForm.js => HouseholdForm.js} | 0 frontend/src/routes/index.js | 2 +- 3 files changed, 46 insertions(+), 17 deletions(-) rename frontend/src/pages/{ HouseholdForm.js => HouseholdForm.js} (100%) diff --git a/django/api/signals.py b/django/api/signals.py index 9759ee75..bc6e8e85 100644 --- a/django/api/signals.py +++ b/django/api/signals.py @@ -34,22 +34,12 @@ def get_email_service_token() -> {}: return -def send_email(recipient_email: str, application_id: str) -> {}: +def send_email(recipient_email: str, application_id: str, message: str, cc_list: list) -> {}: sender_email = settings.EMAIL['SENDER_EMAIL'] sender_name = settings.EMAIL['SENDER_NAME'] url = settings.EMAIL['CHES_EMAIL_URL'] - - body = """ -We have received your application for a rebate under the CleanBC Go Electric Passenger Vehicle Rebate program. - -Please keep this e-mail for your records. - -Questions? - -Please feel free to contact us at ZEVPrograms@gov.bc.ca -""" - - subject = "Application {}".format(application_id) + + subject = "CleanBC Go Electric - Application #{}".format(application_id) bodyType = "html" token = get_email_service_token() @@ -63,8 +53,8 @@ def send_email(recipient_email: str, application_id: str) -> {}: data = { "bcc": [recipient_email], "bodyType": bodyType, - "body": body, - "cc": [], + "body": message, + "cc": cc_list, "delayTS": 0, "encoding": "utf-8", "from": sender_info, @@ -90,9 +80,48 @@ def send_email(recipient_email: str, application_id: str) -> {}: return +def send_individual_confirm(recipient, id): + message = """ + We have received your application for a rebate under the CleanBC Go Electric Passenger Vehicle Rebate program. + + Please keep this e-mail for your records. + + Questions? + + Please feel free to contact us at ZEVPrograms@gov.bc.ca + """ + send_email(recipient, id, message, cc_list=[]) + + +def send_spouse_initial_message(recipient, id, initiator_email): + message = """ + Dear Applicant, + + You are receiving this e-mail as you have been identified as a spouse under a household rebate application for the CleanBC Go Electric Light-Duty Vehicle program. + + To finish the rebate application please click on the following link: + + http://localhost:3000/household?q={} + + Questions? + + Please feel free to contact us at ZEVPrograms@gov.bc.ca + """.format(id) + send_email(recipient, id, message, cc_list=[initiator_email]) + + # TODO have this schedule an email task that's retried in the future incase # CHES has issues when we setup celery. @receiver(post_save, sender=GoElectricRebateApplication) def create_application(sender, instance, created, **kwargs): if created and settings.EMAIL['SEND_EMAIL']: - send_email(instance.email, instance.id) + send_individual_confirm( + recipient=instance.email, + id=instance.id + ) + if instance.application_type == 'household': + send_spouse_initial_message( + recipient=instance.spouse_email, + id=instance.id, + initiator_email=instance.email + ) diff --git a/frontend/src/pages/ HouseholdForm.js b/frontend/src/pages/HouseholdForm.js similarity index 100% rename from frontend/src/pages/ HouseholdForm.js rename to frontend/src/pages/HouseholdForm.js diff --git a/frontend/src/routes/index.js b/frontend/src/routes/index.js index 58fe50dd..03bdfa49 100644 --- a/frontend/src/routes/index.js +++ b/frontend/src/routes/index.js @@ -7,7 +7,7 @@ import FormPage from '../pages/Form'; import AdminPage from '../pages/admin'; import DetailsPage from '../pages/Details'; import HouseholdPage from '../pages/Household'; -import HouseholdFormPage from '../pages/ HouseholdForm'; +import HouseholdFormPage from '../pages/HouseholdForm'; const RequireAuth = ({ children, redirectTo }) => { const { keycloak } = useKeycloak();