Skip to content

Commit

Permalink
Merge branch 'master' into fix_ocado_links
Browse files Browse the repository at this point in the history
  • Loading branch information
faucomte97 authored Sep 26, 2024
2 parents 53f8860 + 04d7c07 commit 9ac53e6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 8 deletions.
2 changes: 1 addition & 1 deletion portal/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "7.3.3"
__version__ = "7.3.4"
43 changes: 36 additions & 7 deletions portal/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions portal/views/cron/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9ac53e6

Please sign in to comment.