From 153ea7e0da3fe1cbf661ee9b886fed0222f0a138 Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Tue, 17 Sep 2024 17:29:51 -0500 Subject: [PATCH 1/9] enhance: WI-154 do not show recaptcha data --- apps/tup-cms/src/apps/portal/apps.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/tup-cms/src/apps/portal/apps.py b/apps/tup-cms/src/apps/portal/apps.py index 6ec38d03b..0286653d1 100644 --- a/apps/tup-cms/src/apps/portal/apps.py +++ b/apps/tup-cms/src/apps/portal/apps.py @@ -49,7 +49,8 @@ def send_confirmation_email(form_name, form_data): if form_name == "Tour Request Form": tour_receipt = "

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

\n" for key in form_data: - tour_receipt += f"

{key}: {form_data[key]}

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

{key}: {form_data[key]}

\n" email_body = f"""

Greetings,

From df0b0ec48eaefb69774c3ae6e95b0f8735ae5b4e Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Tue, 17 Sep 2024 17:48:12 -0500 Subject: [PATCH 2/9] enhance: WI-154 use field labels not keys --- apps/tup-cms/src/apps/portal/apps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/tup-cms/src/apps/portal/apps.py b/apps/tup-cms/src/apps/portal/apps.py index 0286653d1..48a6eacb7 100644 --- a/apps/tup-cms/src/apps/portal/apps.py +++ b/apps/tup-cms/src/apps/portal/apps.py @@ -50,7 +50,7 @@ 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" + tour_receipt += f"

{form_data[key][label]}: {form_data[key]}

\n" email_body = f"""

Greetings,

From 6893d1485d4725b586a20714949c004bbb307a33 Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:37:49 -0500 Subject: [PATCH 3/9] =?UTF-8?q?test:=20tour=20email=20add=20labels=20?= =?UTF-8?q?=E2=9A=A0=EF=B8=8F=20NOT=20WORKING?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tup-cms/project.json | 8 ++++---- apps/tup-cms/src/apps/portal/apps.py | 7 +++++-- apps/tup-cms/src/apps/portal/utils.py | 29 +++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 apps/tup-cms/src/apps/portal/utils.py diff --git a/apps/tup-cms/project.json b/apps/tup-cms/project.json index 9a39f1464..c46fee0ee 100644 --- a/apps/tup-cms/project.json +++ b/apps/tup-cms/project.json @@ -14,7 +14,7 @@ } ], "options": { - "commands": ["docker-compose -f docker-compose.dev.yml build"], + "commands": ["docker compose -f docker-compose.dev.yml build"], "cwd": "apps/tup-cms", "parallel": false } @@ -23,8 +23,8 @@ "executor": "nx:run-commands", "options": { "commands": [ - "docker-compose -f docker-compose.dev.yml stop", - "docker-compose -f docker-compose.dev.yml up" + "docker compose -f docker-compose.dev.yml stop", + "docker compose -f docker-compose.dev.yml up" ], "cwd": "apps/tup-cms", "parallel": false @@ -33,7 +33,7 @@ "down": { "executor": "nx:run-commands", "options": { - "command": "docker-compose -f docker-compose.dev.yml down", + "command": "docker compose -f docker-compose.dev.yml down", "cwd": "apps/tup-cms" } }, diff --git a/apps/tup-cms/src/apps/portal/apps.py b/apps/tup-cms/src/apps/portal/apps.py index 6ec38d03b..3bd06fabd 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 @@ -49,7 +49,10 @@ def send_confirmation_email(form_name, form_data): if form_name == "Tour Request Form": tour_receipt = "

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

\n" for key in form_data: - tour_receipt += f"

{key}: {form_data[key]}

\n" + if not key.startswith('recaptcha_'): + label = reverse_slugify(key) + 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..0581b263d --- /dev/null +++ b/apps/tup-cms/src/apps/portal/utils.py @@ -0,0 +1,29 @@ +"""Utilities for Portal +""" +import re + +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_capitalized = [ + word.capitalize() + if word not in words_to_exclude + else word + for word in words + ] + text = ' '.join(words_capitalized).capitalize() + + return text From 5fa50a2f5b7db2ea32b84819a087b8427274587f Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Thu, 3 Oct 2024 12:56:28 -0500 Subject: [PATCH 4/9] fix: WI-154 ignore `form_id` --- apps/tup-cms/src/apps/portal/apps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/tup-cms/src/apps/portal/apps.py b/apps/tup-cms/src/apps/portal/apps.py index 3bd06fabd..bf2c47922 100644 --- a/apps/tup-cms/src/apps/portal/apps.py +++ b/apps/tup-cms/src/apps/portal/apps.py @@ -49,7 +49,7 @@ def send_confirmation_email(form_name, form_data): if form_name == "Tour Request Form": 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_'): + if not key.startswith('recaptcha_') and key != 'form_id': label = reverse_slugify(key) value = form_data[key] tour_receipt += f"

{label}: {value}

\n" From 83f7e12de7bdbd65d7bd3326364995bd5ca2d1c9 Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:13:50 -0500 Subject: [PATCH 5/9] fix: WI-154 title case properly --- apps/tup-cms/src/apps/portal/utils.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/apps/tup-cms/src/apps/portal/utils.py b/apps/tup-cms/src/apps/portal/utils.py index 0581b263d..30601f24d 100644 --- a/apps/tup-cms/src/apps/portal/utils.py +++ b/apps/tup-cms/src/apps/portal/utils.py @@ -5,7 +5,7 @@ def reverse_slugify(slug): """ - :param str slug: A name that is lowercase and uses hyphens instead of spaces + :param str slug: A name that is title-cased and uses hyphens instead of spaces :rtype: str ..note:: Usage: @@ -18,12 +18,7 @@ def reverse_slugify(slug): words_to_exclude = {'a', 'is', 'to', 'of', 'for', 'and', 'or', 'in'} words = slug.split('-') - words_capitalized = [ - word.capitalize() - if word not in words_to_exclude - else word - for word in words - ] - text = ' '.join(words_capitalized).capitalize() + words_for_title = [ word if word.lower() in words_to_exclude else word.capitalize() for word in words ] + text = words_for_title.join(' ') return text From 10a31427ee0b2043548da6f744980c4860c29139 Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:25:26 -0500 Subject: [PATCH 6/9] fix: WI-154 title case fix has typo --- apps/tup-cms/src/apps/portal/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/tup-cms/src/apps/portal/utils.py b/apps/tup-cms/src/apps/portal/utils.py index 30601f24d..c5c9c1f95 100644 --- a/apps/tup-cms/src/apps/portal/utils.py +++ b/apps/tup-cms/src/apps/portal/utils.py @@ -19,6 +19,6 @@ def reverse_slugify(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 = words_for_title.join(' ') + text = ' '.join(words_for_title) return text From 2446f345efb0320ea70b1bfc4958638887bc3a8f Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:47:52 -0500 Subject: [PATCH 7/9] fix: WI-154 restore form id but title cased well --- apps/tup-cms/src/apps/portal/apps.py | 4 ++-- apps/tup-cms/src/apps/portal/utils.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/tup-cms/src/apps/portal/apps.py b/apps/tup-cms/src/apps/portal/apps.py index bf2c47922..09cf2ac44 100644 --- a/apps/tup-cms/src/apps/portal/apps.py +++ b/apps/tup-cms/src/apps/portal/apps.py @@ -49,8 +49,8 @@ def send_confirmation_email(form_name, form_data): if form_name == "Tour Request Form": 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_') and key != 'form_id': - label = reverse_slugify(key) + if not key.startswith('recaptcha_'): + label = reverse_slugify(key) if key != 'form_id' else 'Form ID' value = form_data[key] tour_receipt += f"

{label}: {value}

\n" diff --git a/apps/tup-cms/src/apps/portal/utils.py b/apps/tup-cms/src/apps/portal/utils.py index c5c9c1f95..34d2abd47 100644 --- a/apps/tup-cms/src/apps/portal/utils.py +++ b/apps/tup-cms/src/apps/portal/utils.py @@ -1,11 +1,10 @@ """Utilities for Portal """ -import re def reverse_slugify(slug): """ - :param str slug: A name that is title-cased and uses hyphens instead of spaces + :param str slug: A name that is lowercase and uses hyphens instead of spaces :rtype: str ..note:: Usage: From e375b3a360b064a23440d4a3e1846c8e261dd671 Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:15:56 -0500 Subject: [PATCH 8/9] refactor: (minor change) to reduce diff --- apps/tup-cms/src/apps/portal/apps.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/tup-cms/src/apps/portal/apps.py b/apps/tup-cms/src/apps/portal/apps.py index 09cf2ac44..9be68341a 100644 --- a/apps/tup-cms/src/apps/portal/apps.py +++ b/apps/tup-cms/src/apps/portal/apps.py @@ -51,8 +51,7 @@ def send_confirmation_email(form_name, form_data): for key in form_data: if not key.startswith('recaptcha_'): label = reverse_slugify(key) if key != 'form_id' else 'Form ID' - value = form_data[key] - tour_receipt += f"

{label}: {value}

\n" + tour_receipt += f"

{label}: {form_data[key]}

\n" email_body = f"""

Greetings,

From 5a38fa77cf7cd2b2b2b028dc6b65979e262955bc Mon Sep 17 00:00:00 2001 From: Wesley B <62723358+wesleyboar@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:17:07 -0500 Subject: [PATCH 9/9] Revert "refactor: (minor change) to reduce diff" This reverts commit e375b3a360b064a23440d4a3e1846c8e261dd671. --- apps/tup-cms/src/apps/portal/apps.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/tup-cms/src/apps/portal/apps.py b/apps/tup-cms/src/apps/portal/apps.py index 9be68341a..09cf2ac44 100644 --- a/apps/tup-cms/src/apps/portal/apps.py +++ b/apps/tup-cms/src/apps/portal/apps.py @@ -51,7 +51,8 @@ def send_confirmation_email(form_name, form_data): for key in form_data: if not key.startswith('recaptcha_'): label = reverse_slugify(key) if key != 'form_id' else 'Form ID' - tour_receipt += f"

{label}: {form_data[key]}

\n" + value = form_data[key] + tour_receipt += f"

{label}: {value}

\n" email_body = f"""

Greetings,