Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Emails] Update trigger for the host-instructor introduction #2699

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading