Skip to content

Commit

Permalink
Merge pull request #2724 from carpentries/feature/2723-instructor-con…
Browse files Browse the repository at this point in the history
…firmed-for-workshop-additional-condition

[Emails] Add condition for event in future in Instructor Confirmed for Workshop
  • Loading branch information
pbanaszkiewicz authored Nov 19, 2024
2 parents 2fd7d0a + 2d21f44 commit 2d8d8fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions amy/emails/actions/instructor_confirmed_for_workshop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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 = (
Expand All @@ -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=}")

Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
Expand All @@ -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])
Expand Down

0 comments on commit 2d8d8fb

Please sign in to comment.