Skip to content

Commit

Permalink
CMD-112 Let Client CMS Overwrite Core-CMS Confirmation Email (#826)
Browse files Browse the repository at this point in the history
* CMD-112 Let Client CMS Overwrite Core-CMS Confirmation Email

* dont overwrite the files. just the copy we receive from it.

* move email_management to somewhere that makes sense

* fix: cmd-112 missing piece of recent change

* fix: cmd-112 another missing piece

* cleanup architecture

* cleanup path to assets in email.py

* use django setting instead of file

* refactor: CMD-112 rename settings

---------

Co-authored-by: Wesley Bomar <wbomar@tacc.utexas.edu>
  • Loading branch information
R-Tomas-Gonzalez and wesleyboar authored Apr 1, 2024
1 parent 17adb6a commit 557abeb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
28 changes: 10 additions & 18 deletions common_apps/email_management/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from django.conf import settings

PORTAL_SHOULD_SEND_CONF_EMAIL = settings.PORTAL_SHOULD_SEND_CONF_EMAIL
TEXT_CONFIRMATION_EMAIL = settings.PORTAL_CONF_EMAIL_TEXT
HTML_CONFIRMATION_EMAIL = settings.PORTAL_CONF_EMAIL_HTML

logger = logging.getLogger(f"portal.{__name__}")

Expand All @@ -18,24 +20,14 @@ def send_confirmation_email(form_name, form_data):
# Get the site name
site_name = current_site.name

text_body = f"""
Greetings,
You have successfully submitted a form on the {site_name} website. Thank you for your submission.
Sincerely,
{site_name} Communications
"""
email_body = f"""
<p>Greetings,</p>
<p>
You have successfully submitted a form on the {site_name} website. Thank you for your submission.
</p>
<p>
Sincerely,<br>
{site_name} Communications
</p>
"""
def replace_word_in_file(email_content):

modified_content = email_content.replace('{site_name}', f'{site_name}')
return modified_content

text_body = replace_word_in_file(TEXT_CONFIRMATION_EMAIL)
email_body = replace_word_in_file(HTML_CONFIRMATION_EMAIL)

send_mail(
f"TACC Form Submission Received: {form_name}",
text_body,
Expand Down
21 changes: 21 additions & 0 deletions taccsite_cms/_settings/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,24 @@
########################

PORTAL_SHOULD_SEND_CONF_EMAIL = False

PORTAL_CONF_EMAIL_TEXT = """
Greetings,
You have successfully submitted a form on the {site_name} website. Thank you for your submission.
Sincerely,
{site_name} Communications
"""

PORTAL_CONF_EMAIL_HTML = """
<p>Greetings,</p>
<p>
You have successfully submitted a form on the {site_name} website. Thank you
for your submission.
</p>
<p>
Sincerely,<br />
{site_name} Communications
</p>
"""

0 comments on commit 557abeb

Please sign in to comment.