diff --git a/bloclink/apps/bis/views.py b/bloclink/apps/bis/views.py index 7b06ce1ea85a54f14c70c20495fbe00e98a6f3d1..f087718f155565722490137f50a13ffb3c50ef79 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 0000000000000000000000000000000000000000..0e7b8915a61559e17527d6b23d2da6a6591cd8eb --- /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 }}