-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'task/TUP-528--form-email-confirmation' into dev
- Loading branch information
Showing
3 changed files
with
26 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
from django.dispatch import receiver | ||
from djangocms_forms.signals import form_submission | ||
from django.conf import settings | ||
from django.core.mail import send_mail | ||
|
||
|
||
logger = logging.getLogger(f"portal.{__name__}") | ||
|
@@ -42,10 +43,31 @@ def submit_ticket(form_data): | |
requests.post(f"{service_url}/tickets/noauth", data=ticket_data, files=[]) | ||
|
||
|
||
def send_confirmation_email(form_name, form_data): | ||
email_body = """ | ||
<p>Hello,</p> | ||
<p> | ||
Thank you for submitting a form on the TACC website. | ||
</p> | ||
<p> | ||
We will act on your request according to the information provided on the form webpage. | ||
</p> | ||
- TACC | ||
""" | ||
send_mail( | ||
f"TACC Form Submission Received: {form_name}", | ||
email_body, | ||
"[email protected]", | ||
[form_data["email"]], | ||
html_message=email_body) | ||
|
||
|
||
def callback(form, cleaned_data, **kwargs): | ||
logger.debug(f"received submission from {form.name}") | ||
if form.name == 'rt-ticket-form': | ||
submit_ticket(cleaned_data) | ||
else: | ||
send_confirmation_email(form.name, cleaned_data) | ||
|
||
|
||
class PortalConfig(AppConfig): | ||
|
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