Skip to content

Commit

Permalink
-renames household form, removes leading space (bcgov#73)
Browse files Browse the repository at this point in the history
-updates household form import in index
-adds spouse initial email to signals, restructures email function to accept more arguments
  • Loading branch information
emi-hi authored Apr 14, 2022
1 parent 0f12c91 commit 1854c6c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 17 deletions.
61 changes: 45 additions & 16 deletions django/api/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]
"""

subject = "Application {}".format(application_id)

subject = "CleanBC Go Electric - Application #{}".format(application_id)
bodyType = "html"

token = get_email_service_token()
Expand All @@ -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,
Expand All @@ -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 [email protected]
"""
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 [email protected]
""".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
)
File renamed without changes.
2 changes: 1 addition & 1 deletion frontend/src/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 1854c6c

Please sign in to comment.