From ee50987efb571d2e9bc721e89da17e7be5213963 Mon Sep 17 00:00:00 2001
From: Florian Aucomte <33633200+faucomte97@users.noreply.github.com>
Date: Thu, 15 Jun 2023 16:11:25 +0100
Subject: [PATCH 1/7] fix: Update Gtag reference to new GA4 (#2099)
* fix: Update Gtag reference to new GA4
* Merge branch 'master' into ga4_upgrade
---
portal/templates/portal/base.html | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/portal/templates/portal/base.html b/portal/templates/portal/base.html
index 5e207591d..3aeb9cb13 100644
--- a/portal/templates/portal/base.html
+++ b/portal/templates/portal/base.html
@@ -52,24 +52,14 @@
{% block google_analytics %}
{% if request|is_production %}
+
+
From 5f4d68c0604611cb271fcadc9d2a173bc9db1496 Mon Sep 17 00:00:00 2001
From: Chi-En Wei <65698922+cewei8483@users.noreply.github.com>
Date: Fri, 16 Jun 2023 11:40:55 +0100
Subject: [PATCH 2/7] fix: 1454 shorten url in aws emails (#2101)
* make url shorter
* modify other functions involved
* clean up
* Merge branch 'master' into 1454-shorten-url-in-aws-emails
---
cfl_common/common/email_messages.py | 6 +++++-
cfl_common/common/helpers/emails.py | 18 +++++++++++++-----
2 files changed, 18 insertions(+), 6 deletions(-)
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"])
From c12eb7ec47328f401407a2116b0e349632bfabba Mon Sep 17 00:00:00 2001
From: faucomte97
Date: Fri, 16 Jun 2023 11:56:42 +0100
Subject: [PATCH 3/7] fix: Go back to actual semantic release repo
---
.github/workflows/publish-python-package.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/publish-python-package.yml b/.github/workflows/publish-python-package.yml
index 5759f8f31..55526f595 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: python-semantic-release/python-semantic-release
with:
github_token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
pypi_token: ${{ secrets.PYPI_TOKEN }}
From a85994dbd8a30bd18df76523f381ac3a8290e19a Mon Sep 17 00:00:00 2001
From: faucomte97
Date: Fri, 16 Jun 2023 11:59:02 +0100
Subject: [PATCH 4/7] fix: Correct repo name
---
.github/workflows/publish-python-package.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/publish-python-package.yml b/.github/workflows/publish-python-package.yml
index 55526f595..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: python-semantic-release/python-semantic-release
+ uses: relekang/python-semantic-release@master
with:
github_token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
pypi_token: ${{ secrets.PYPI_TOKEN }}
From 6f47820b125a11ab458470eb7b9fa732c41b6598 Mon Sep 17 00:00:00 2001
From: github-actions
Date: Fri, 16 Jun 2023 11:03:45 +0000
Subject: [PATCH 5/7] 6.31.1
Automatically generated by python-semantic-release
---
CHANGELOG.md | 9 +++++++++
portal/__init__.py | 2 +-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4a40db026..286b8d735 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,15 @@
+## 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/portal/__init__.py b/portal/__init__.py
index 6c9b2f045..d768fa07b 100644
--- a/portal/__init__.py
+++ b/portal/__init__.py
@@ -1 +1 @@
-__version__ = "6.31.0"
+__version__ = "6.31.1"
From eb074d521f03470aaa28293790302e2559884763 Mon Sep 17 00:00:00 2001
From: Florian Aucomte <33633200+faucomte97@users.noreply.github.com>
Date: Fri, 16 Jun 2023 17:37:00 +0100
Subject: [PATCH 6/7] fix: Allow more scripts from GTM in CSP (#2103)
---
cfl_common/common/csp_config.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/cfl_common/common/csp_config.py b/cfl_common/common/csp_config.py
index 2ec8a34a7..1c06b5666 100644
--- a/cfl_common/common/csp_config.py
+++ b/cfl_common/common/csp_config.py
@@ -28,9 +28,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/",
From 69d6aa2708f7c96de84969709ebff3df25b3e710 Mon Sep 17 00:00:00 2001
From: github-actions
Date: Fri, 16 Jun 2023 16:40:36 +0000
Subject: [PATCH 7/7] 6.31.2
Automatically generated by python-semantic-release
---
CHANGELOG.md | 6 ++++++
portal/__init__.py | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 286b8d735..c4a5dad1b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,12 @@
+## 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
diff --git a/portal/__init__.py b/portal/__init__.py
index d768fa07b..1bc7070d6 100644
--- a/portal/__init__.py
+++ b/portal/__init__.py
@@ -1 +1 @@
-__version__ = "6.31.1"
+__version__ = "6.31.2"