diff --git a/apps/tup-cms/src/apps/portal/apps.py b/apps/tup-cms/src/apps/portal/apps.py index 0286653d1..09cf2ac44 100644 --- a/apps/tup-cms/src/apps/portal/apps.py +++ b/apps/tup-cms/src/apps/portal/apps.py @@ -5,7 +5,7 @@ from djangocms_forms.signals import form_submission from django.conf import settings from django.core.mail import send_mail - +from .utils import reverse_slugify logger = logging.getLogger(f"portal.{__name__}") service_url = settings.TUP_SERVICES_URL @@ -50,7 +50,9 @@ def send_confirmation_email(form_name, form_data): tour_receipt = "

A copy of your tour request is provided below for your records:

\n" for key in form_data: if not key.startswith('recaptcha_'): - tour_receipt += f"

{key}: {form_data[key]}

\n" + label = reverse_slugify(key) if key != 'form_id' else 'Form ID' + value = form_data[key] + tour_receipt += f"

{label}: {value}

\n" email_body = f"""

Greetings,

diff --git a/apps/tup-cms/src/apps/portal/utils.py b/apps/tup-cms/src/apps/portal/utils.py new file mode 100644 index 000000000..34d2abd47 --- /dev/null +++ b/apps/tup-cms/src/apps/portal/utils.py @@ -0,0 +1,23 @@ +"""Utilities for Portal +""" + +def reverse_slugify(slug): + """ + + :param str slug: A name that is lowercase and uses hyphens instead of spaces + :rtype: str + + ..note:: Usage: + ``` + slug = "and-hello-world-this-is-a-slug" + original_text = reverse_slugify(slug) + print(original_text) # Output: "And Hello World This is a Slug" + ``` + """ + + words_to_exclude = {'a', 'is', 'to', 'of', 'for', 'and', 'or', 'in'} + words = slug.split('-') + words_for_title = [ word if word.lower() in words_to_exclude else word.capitalize() for word in words ] + text = ' '.join(words_for_title) + + return text