Skip to content

Commit

Permalink
Merge pull request #2699 from carpentries/bugfix/2695-update-trigger-…
Browse files Browse the repository at this point in the history
…for-host-instructor-introduction

[Emails] Update trigger for the host-instructor introduction
  • Loading branch information
pbanaszkiewicz authored Sep 15, 2024
2 parents 8fefdc2 + 88c326f commit 25f64d9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
13 changes: 11 additions & 2 deletions amy/recruitment/tests/test_instructor_recruitment_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
CommunityRoleConfig,
CommunityRoleInactivation,
)
from emails.types import StrategyEnum
from recruitment.filters import InstructorRecruitmentFilter
from recruitment.forms import (
InstructorRecruitmentAddSignupForm,
Expand Down Expand Up @@ -983,8 +984,12 @@ def test_close_recruitment__failure(self) -> None:
)
self.assertEqual(result.status_code, 302)

def test_close_recruitment__success(self) -> None:
@mock.patch("recruitment.views.host_instructors_introduction_strategy")
def test_close_recruitment__success(
self, mock_host_instructors_introduction_strategy: mock.MagicMock
) -> None:
# Arrange
mock_host_instructors_introduction_strategy.return_value = StrategyEnum.NOOP
request = RequestFactory().post("/")
view = InstructorRecruitmentChangeState(request=request)
view._validate_for_closing = mock.MagicMock(return_value=True)
Expand Down Expand Up @@ -1039,8 +1044,12 @@ def test_reopen_recruitment__failure(self) -> None:
)
self.assertEqual(result.status_code, 302)

def test_reopen_recruitment__success(self) -> None:
@mock.patch("recruitment.views.host_instructors_introduction_strategy")
def test_reopen_recruitment__success(
self, mock_host_instructors_introduction_strategy: mock.MagicMock
) -> None:
# Arrange
mock_host_instructors_introduction_strategy.return_value = StrategyEnum.NOOP
request = RequestFactory().post("/")
view = InstructorRecruitmentChangeState(request=request)
view._validate_for_reopening = mock.MagicMock(return_value=True)
Expand Down
16 changes: 16 additions & 0 deletions amy/recruitment/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
import django_rq
from flags.views import FlaggedViewMixin

from emails.actions.host_instructors_introduction import (
host_instructors_introduction_strategy,
run_host_instructors_introduction_strategy,
)
from emails.signals import (
admin_signs_instructor_up_for_workshop_signal,
instructor_confirmed_for_workshop_signal,
Expand Down Expand Up @@ -522,6 +526,12 @@ def close_recruitment(self) -> HttpResponse:
f"Successfully closed recruitment {self.object}.",
)

run_host_instructors_introduction_strategy(
host_instructors_introduction_strategy(self.object.event),
self.request,
self.object.event,
)

return HttpResponseRedirect(self.get_success_url())

@staticmethod
Expand All @@ -544,6 +554,12 @@ def reopen_recruitment(self) -> HttpResponse:
self.request, f"Successfully re-opened recruitment {self.object}."
)

run_host_instructors_introduction_strategy(
host_instructors_introduction_strategy(self.object.event),
self.request,
self.object.event,
)

return HttpResponseRedirect(self.get_success_url())

def form_valid(self, form: BaseForm) -> HttpResponse:
Expand Down

0 comments on commit 25f64d9

Please sign in to comment.