From 3b5dcc68cd36aa7db4fc97a237e5954f03de23bf Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Wed, 11 Mar 2020 16:15:54 -0400 Subject: [PATCH 1/2] Add feature to send email to dev when new ID is generated --- bloclink/apps/bis/views.py | 20 ++++++++++++++++++++ bloclink/templates/dev_notification.html | 10 ++++++++++ 2 files changed, 30 insertions(+) create mode 100644 bloclink/templates/dev_notification.html diff --git a/bloclink/apps/bis/views.py b/bloclink/apps/bis/views.py index 7b06ce1..f087718 100644 --- a/bloclink/apps/bis/views.py +++ b/bloclink/apps/bis/views.py @@ -588,4 +588,24 @@ class SubmitQuestionnaire(View): if pns_report: msg.attach_file(pns_report) msg.send() + + # Send email to dev if the building ID was created. + if os.environ['ENVIRONMENT'] == 'prod' and put['buildingId'] > 1189760: + connection = get_connection(host=settings.EMAIL_HOST, + port=settings.EMAIL_PORT, + username=settings.EMAIL_USERNAME, + password=settings.EMAIL_PASSWORD, + use_tls=settings.EMAIL_USE_TLS) + from_email = settings.EMAIL_USERNAME + msg_html = render_to_string('dev_notification.html', {'firstName': put['firstName'], + 'lastName': put['lastName'], + 'email': put['email'], + 'contactNumber': put['phone'], + 'buildingId': put['buildingId'], + 'address': buildingData['address']}) + subject = 'BIS - New building ID created.' + email_recipient = settings.TEST_EMAIL + msg = EmailMessage(subject, msg_html, from_email, [email_recipient], connection=connection) + msg.content_subtype = "html" + msg.send() return True diff --git a/bloclink/templates/dev_notification.html b/bloclink/templates/dev_notification.html new file mode 100644 index 0000000..161b267 --- /dev/null +++ b/bloclink/templates/dev_notification.html @@ -0,0 +1,10 @@ +A new Building ID has been created for the building. +Please find all the information here. +

+ +First Name: {{ firstName }}
+Last Name: {{ lastName }}
+Email: {{ email }}
+Contact Number: {{ contactNumber }}
+Building ID: {{ buildingId }}
+Building Address: {{ address }}
\ No newline at end of file -- GitLab From 6c3d67438e62afc255aafb2e12f5226af8e63e80 Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Wed, 11 Mar 2020 16:20:47 -0400 Subject: [PATCH 2/2] Add line break --- bloclink/templates/dev_notification.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bloclink/templates/dev_notification.html b/bloclink/templates/dev_notification.html index 161b267..0e7b891 100644 --- a/bloclink/templates/dev_notification.html +++ b/bloclink/templates/dev_notification.html @@ -7,4 +7,4 @@ Please find all the information here. Email: {{ email }}
Contact Number: {{ contactNumber }}
Building ID: {{ buildingId }}
-Building Address: {{ address }}
\ No newline at end of file +Building Address: {{ address }}
-- GitLab