diff --git a/.github/workflows/publish-python-package.yml b/.github/workflows/publish-python-package.yml index 5759f8f31..c86be2ae6 100644 --- a/.github/workflows/publish-python-package.yml +++ b/.github/workflows/publish-python-package.yml @@ -36,7 +36,7 @@ jobs: yarn build mv build ../portal/frontend - name: Release codeforlife-portal - uses: ocadotechnology/python-semantic-release@patch-packaging-error + uses: relekang/python-semantic-release@master with: github_token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} pypi_token: ${{ secrets.PYPI_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a40db026..c4a5dad1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,21 @@ +## v6.31.2 (2023-06-16) + +### Fix + +* Allow more scripts from GTM in CSP ([#2103](https://github.com/ocadotechnology/codeforlife-portal/issues/2103)) ([`eb074d5`](https://github.com/ocadotechnology/codeforlife-portal/commit/eb074d521f03470aaa28293790302e2559884763)) + +## v6.31.1 (2023-06-16) + +### Fix + +* Correct repo name ([`a85994d`](https://github.com/ocadotechnology/codeforlife-portal/commit/a85994dbd8a30bd18df76523f381ac3a8290e19a)) +* Go back to actual semantic release repo ([`c12eb7e`](https://github.com/ocadotechnology/codeforlife-portal/commit/c12eb7ec47328f401407a2116b0e349632bfabba)) +* 1454 shorten url in aws emails ([#2101](https://github.com/ocadotechnology/codeforlife-portal/issues/2101)) ([`5f4d68c`](https://github.com/ocadotechnology/codeforlife-portal/commit/5f4d68c0604611cb271fcadc9d2a173bc9db1496)) +* Update Gtag reference to new GA4 ([#2099](https://github.com/ocadotechnology/codeforlife-portal/issues/2099)) ([`ee50987`](https://github.com/ocadotechnology/codeforlife-portal/commit/ee50987efb571d2e9bc721e89da17e7be5213963)) + ## v6.31.0 (2023-06-14) ### Feature * Remove intermediate pages and go direct to gitbook resources ([#2098](https://github.com/ocadotechnology/codeforlife-portal/issues/2098)) ([`2c6cb61`](https://github.com/ocadotechnology/codeforlife-portal/commit/2c6cb61b9753ecaa610e0d3d479ac5cf3eaf7210)) diff --git a/cfl_common/common/csp_config.py b/cfl_common/common/csp_config.py index 351d33eeb..206f57499 100644 --- a/cfl_common/common/csp_config.py +++ b/cfl_common/common/csp_config.py @@ -30,9 +30,8 @@ "https://euc-widget.freshworks.com/", "https://cdn-ukwest.onetrust.com/", "https://code.iconify.design/2/2.0.3/iconify.min.js", - "https://www.googletagmanager.com/gtm.js", + "https://www.googletagmanager.com/", "https://cdn.mouseflow.com/", - "https://www.google-analytics.com/analytics.js", "https://www.recaptcha.net/", "https://www.google.com/recaptcha/", "https://www.gstatic.com/recaptcha/", diff --git a/cfl_common/common/email_messages.py b/cfl_common/common/email_messages.py index 03fba9162..e67ea2d5d 100644 --- a/cfl_common/common/email_messages.py +++ b/cfl_common/common/email_messages.py @@ -24,6 +24,7 @@ def emailVerificationNeededEmail(request, token): f"Please go to {url} to verify your email address.\n\nBy activating the account you confirm that you have " f"read and agreed to our terms ({terms_url}) and our privacy notice ({privacy_notice_url})." ), + "url": {"verify_url": url}, } @@ -43,18 +44,21 @@ def parentsEmailVerificationNeededEmail(request, user, token): f"account you confirm that you have read and agreed to our terms ({terms_url}) and our privacy notice " f"({privacy_notice_url})." ), + "url": {"verify_url": url}, } def emailChangeVerificationEmail(request, token): + url = f"{request.build_absolute_uri(reverse('verify_email', kwargs={'token': token}))}" return { "subject": f"Email verification needed", "message": ( f"You are changing your email, please go to " - f"{request.build_absolute_uri(reverse('verify_email', kwargs={'token': token}))} " + f"{url} " f"to verify your new email address. If you are not part of Code for Life " f"then please ignore this email." ), + "url": {"verify_url": url}, } diff --git a/cfl_common/common/helpers/emails.py b/cfl_common/common/helpers/emails.py index 7d9a40100..80ace5df7 100644 --- a/cfl_common/common/helpers/emails.py +++ b/cfl_common/common/helpers/emails.py @@ -1,5 +1,6 @@ import datetime import json +import re from enum import Enum, auto from uuid import uuid4 @@ -41,6 +42,7 @@ def send_email( subject, text_content, title, + replace_url=None, plaintext_template="email.txt", html_template="email.html", ): @@ -54,7 +56,13 @@ def send_email( # render templates plaintext_body = plaintext.render(plaintext_email_context) - html_body = html.render(html_email_context) + original_html_body = html.render(html_email_context) + html_body = original_html_body + + if replace_url: + verify_url = replace_url["verify_url"] + verify_replace_url = re.sub(f'(.*/verify_email/)(.*)', f'\\1', verify_url) + html_body = re.sub(f'({verify_url})(.*){verify_url}', f'\\1\\2{verify_replace_url}', original_html_body) # make message using templates message = EmailMultiAlternatives(subject, plaintext_body, sender, recipients) @@ -113,7 +121,7 @@ def send_verification_email(request, user, data, new_email=None, age=None): # if the user is a teacher if age is None: message = emailVerificationNeededEmail(request, verification) - send_email(VERIFICATION_EMAIL, [user.email], message["subject"], message["message"], message["subject"]) + send_email(VERIFICATION_EMAIL, [user.email], message["subject"], message["message"], message["subject"], replace_url=message["url"]) if _newsletter_ticked(data): add_to_dotmailer(user.first_name, user.last_name, user.email, DotmailerUserType.TEACHER) @@ -121,10 +129,10 @@ def send_verification_email(request, user, data, new_email=None, age=None): else: if age < 13: message = parentsEmailVerificationNeededEmail(request, user, verification) - send_email(VERIFICATION_EMAIL, [user.email], message["subject"], message["message"], message["subject"]) + send_email(VERIFICATION_EMAIL, [user.email], message["subject"], message["message"], message["subject"], replace_url=message["url"]) else: message = emailVerificationNeededEmail(request, verification) - send_email(VERIFICATION_EMAIL, [user.email], message["subject"], message["message"], message["subject"]) + send_email(VERIFICATION_EMAIL, [user.email], message["subject"], message["message"], message["subject"], replace_url=message["url"]) if _newsletter_ticked(data): add_to_dotmailer(user.first_name, user.last_name, user.email, DotmailerUserType.STUDENT) @@ -133,7 +141,7 @@ def send_verification_email(request, user, data, new_email=None, age=None): verification = generate_token(user, new_email) message = emailChangeVerificationEmail(request, verification) - send_email(VERIFICATION_EMAIL, [user.email], message["subject"], message["message"], message["subject"]) + send_email(VERIFICATION_EMAIL, [user.email], message["subject"], message["message"], message["subject"], replace_url=message["url"]) message = emailChangeNotificationEmail(request, new_email) send_email(VERIFICATION_EMAIL, [user.email], message["subject"], message["message"], message["subject"]) diff --git a/portal/__init__.py b/portal/__init__.py index 6c9b2f045..1bc7070d6 100644 --- a/portal/__init__.py +++ b/portal/__init__.py @@ -1 +1 @@ -__version__ = "6.31.0" +__version__ = "6.31.2" diff --git a/portal/templates/portal/base.html b/portal/templates/portal/base.html index 03ef749a6..e48d279a3 100644 --- a/portal/templates/portal/base.html +++ b/portal/templates/portal/base.html @@ -53,24 +53,14 @@ {% block google_analytics %} {% if request|is_production %} + +