From 2046004598dc20ad4d30ded3c581eaf3fea8ad95 Mon Sep 17 00:00:00 2001 From: Florian Aucomte Date: Thu, 26 Sep 2024 11:56:20 +0100 Subject: [PATCH 1/2] fix: Add personalisation values to reminder emails (#2357) --- portal/tests/test_views.py | 43 +++++++++++++++++++++++++++++++------- portal/views/cron/user.py | 9 ++++++++ 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/portal/tests/test_views.py b/portal/tests/test_views.py index 1d624546f..9455121ac 100644 --- a/portal/tests/test_views.py +++ b/portal/tests/test_views.py @@ -40,7 +40,12 @@ from deploy import captcha from portal.templatetags.app_tags import is_logged_in_as_admin_teacher from portal.views.api import anonymise -from portal.views.cron.user import USER_DELETE_UNVERIFIED_ACCOUNT_DAYS +from portal.views.cron.user import ( + USER_DELETE_UNVERIFIED_ACCOUNT_DAYS, + USER_2ND_INACTIVE_REMINDER_DAYS, + USER_FINAL_INACTIVE_REMINDER_DAYS, + USER_RETENTION_PERIOD, +) from portal.views.teacher.teach import ( REMINDER_CARDS_PDF_COLUMNS, REMINDER_CARDS_PDF_ROWS, @@ -1238,6 +1243,7 @@ def send_inactivity_reminder( assert_called: bool, campaign_name: str, mock_send_dotdigital_email: Mock, + personalization_values=None, ): self.teacher_user.date_joined = timezone.now() - timedelta( days=days, hours=12 @@ -1255,13 +1261,28 @@ def send_inactivity_reminder( self.client.get(reverse(view_name)) if assert_called: - mock_send_dotdigital_email.assert_any_call( - campaign_ids[campaign_name], [self.teacher_user.email] - ) + if personalization_values is not None: + mock_send_dotdigital_email.assert_any_call( + campaign_ids[campaign_name], + [self.teacher_user.email], + personalization_values=personalization_values, + ) - mock_send_dotdigital_email.assert_any_call( - campaign_ids[campaign_name], [self.indy_user.email] - ) + mock_send_dotdigital_email.assert_any_call( + campaign_ids[campaign_name], + [self.indy_user.email], + personalization_values=personalization_values, + ) + else: + mock_send_dotdigital_email.assert_any_call( + campaign_ids[campaign_name], + [self.teacher_user.email], + ) + + mock_send_dotdigital_email.assert_any_call( + campaign_ids[campaign_name], + [self.indy_user.email], + ) # Check only two emails are sent - the student should never be included. assert mock_send_dotdigital_email.call_count == 2 @@ -1302,6 +1323,10 @@ def test_second_inactivity_reminder_view(self): "second-inactivity-reminder", True, "inactive_users_on_website_second_reminder", + personalization_values={ + "DAYS_LEFT": USER_RETENTION_PERIOD + - USER_2ND_INACTIVE_REMINDER_DAYS + }, ) self.send_inactivity_reminder( 974, @@ -1322,6 +1347,10 @@ def test_final_inactivity_reminder_view(self): "final-inactivity-reminder", True, "inactive_users_on_website_final_reminder", + personalization_values={ + "DAYS_LEFT": USER_RETENTION_PERIOD + - USER_FINAL_INACTIVE_REMINDER_DAYS + }, ) self.send_inactivity_reminder( 1066, diff --git a/portal/views/cron/user.py b/portal/views/cron/user.py index 488626dd8..9531703dc 100644 --- a/portal/views/cron/user.py +++ b/portal/views/cron/user.py @@ -22,6 +22,7 @@ USER_1ST_INACTIVE_REMINDER_DAYS = 730 # 2 years USER_2ND_INACTIVE_REMINDER_DAYS = 973 # roughly 2 years and 8 months USER_FINAL_INACTIVE_REMINDER_DAYS = 1065 # 2 years and 11 months +USER_RETENTION_PERIOD = 1096 # 3 years def get_unverified_users( @@ -266,6 +267,10 @@ def get(self, request): "inactive_users_on_website_second_reminder" ], [email], + personalization_values={ + "DAYS_LEFT": USER_RETENTION_PERIOD + - USER_2ND_INACTIVE_REMINDER_DAYS + }, ) sent_email_count += 1 @@ -300,6 +305,10 @@ def get(self, request): "inactive_users_on_website_final_reminder" ], [email], + personalization_values={ + "DAYS_LEFT": USER_RETENTION_PERIOD + - USER_FINAL_INACTIVE_REMINDER_DAYS + }, ) sent_email_count += 1 From 04d7c07f257f2b2aaa20921ec356a00b53495fe0 Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 26 Sep 2024 10:58:31 +0000 Subject: [PATCH 2/2] 7.3.4 Automatically generated by python-semantic-release --- portal/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/portal/__init__.py b/portal/__init__.py index 40d114c5b..b5d700de1 100644 --- a/portal/__init__.py +++ b/portal/__init__.py @@ -1 +1 @@ -__version__ = "7.3.3" +__version__ = "7.3.4"