diff --git a/amy/emails/actions/instructor_confirmed_for_workshop.py b/amy/emails/actions/instructor_confirmed_for_workshop.py index 8f5953751..dab4aa044 100644 --- a/amy/emails/actions/instructor_confirmed_for_workshop.py +++ b/amy/emails/actions/instructor_confirmed_for_workshop.py @@ -4,6 +4,7 @@ from django.contrib.contenttypes.models import ContentType from django.http import HttpRequest +from django.utils import timezone from typing_extensions import Unpack from emails.actions.base_action import BaseAction, BaseActionCancel, BaseActionUpdate @@ -48,6 +49,9 @@ def instructor_confirmed_for_workshop_strategy( centrally_organised = ( task.event.administrator and task.event.administrator.domain != "self-organized" ) + start_date_in_future = ( + task.event.start and task.event.start >= timezone.now().date() + ) log_condition_elements( task=task, @@ -57,6 +61,7 @@ def instructor_confirmed_for_workshop_strategy( person_email_exists=person_email_exists, carpentries_tags=carpentries_tags, centrally_organised=centrally_organised, + start_date_in_future=start_date_in_future, ) email_should_exist = ( @@ -65,6 +70,7 @@ def instructor_confirmed_for_workshop_strategy( and person_email_exists and carpentries_tags and centrally_organised + and start_date_in_future ) logger.debug(f"{email_should_exist=}") diff --git a/amy/emails/tests/actions/test_instructor_confirmed_for_workshop_strategy.py b/amy/emails/tests/actions/test_instructor_confirmed_for_workshop_strategy.py index 5d97c1ade..acc112af5 100644 --- a/amy/emails/tests/actions/test_instructor_confirmed_for_workshop_strategy.py +++ b/amy/emails/tests/actions/test_instructor_confirmed_for_workshop_strategy.py @@ -1,7 +1,8 @@ -from datetime import UTC, date, datetime +from datetime import UTC, date, datetime, timedelta from unittest.mock import MagicMock, patch from django.test import RequestFactory, TestCase +from django.utils import timezone from emails.actions.exceptions import EmailStrategyException from emails.actions.instructor_confirmed_for_workshop import ( @@ -21,8 +22,8 @@ def setUp(self) -> None: slug="test-event", host=host, administrator=host, - start=date(2024, 8, 5), - end=date(2024, 8, 5), + start=timezone.now().date() + timedelta(days=2), + end=timezone.now().date() + timedelta(days=3), ) swc_tag = Tag.objects.create(name="SWC") self.event.tags.set([swc_tag])