Skip to content

Commit

Permalink
fix(admissions): send email when applicant interview is moved
Browse files Browse the repository at this point in the history
  • Loading branch information
alexaor committed Aug 27, 2024
1 parent 3d8541a commit f93bc01
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
5 changes: 4 additions & 1 deletion admissions/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
send_new_interview_mail,
send_interview_cancelled_email,
notify_interviewers_cancelled_interview_email,
notify_interviewers_applicant_has_been_moved_to_another_interview_email,
send_interview_confirmation_email,
remove_applicant_choice,
construct_new_priority_list,
Expand Down Expand Up @@ -1985,7 +1986,9 @@ def mutate(self, info, applicant_id, interview_id, *args, **kwargs):
applicant.save()

send_new_interview_mail(applicant)
# TODO send email to interviewers
notify_interviewers_applicant_has_been_moved_to_another_interview_email(
applicant, interview
)

return AssignApplicantNewInterviewMutation(success=True)

Expand Down
65 changes: 65 additions & 0 deletions admissions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,71 @@ def send_interview_cancelled_email(applicant):
)


def notify_interviewers_applicant_has_been_moved_to_another_interview_email(
applicant, interview
):
local_time = timezone.localtime(
interview.interview_start, pytz.timezone(settings.TIME_ZONE)
)
name = applicant.get_full_name
interview_location = interview.location.name
formatted_local_time = local_time.strftime("%d.%m.%Y kl. %H:%M")
content = (
_(
"""
Hei!
%(name)s sitt intervju har blitt flyttet
Du har blitt fjernet fra intervjuet.
Gammel Intervjuinformasjon:
%(interview_location)s
%(interview_time)s
"""
)
% {
"name": name,
"interview_location": interview_location,
"interview_time": formatted_local_time,
}
)

html_content = (
_(
"""
Hei!
<br />
%(name)s sitt intervju har blitt flyttet
<br />
Du har blitt fjernet fra intervjuet.
<br />
Gammel intervjuinformasjon:
<br />
%(interview_location)s
<br />
%(interview_time)s
<br />
"""
)
% {
"name": name,
"interview_location": interview_location,
"interview_time": formatted_local_time,
}
)

return send_email(
_("Flyttet intervju"),
message=content,
html_message=html_content,
recipients=[],
bcc=interview.interviewers.values_list("email", flat=True),
)


def notify_interviewers_cancelled_interview_email(applicant, interview):
local_time = timezone.localtime(
interview.interview_start, pytz.timezone(settings.TIME_ZONE)
Expand Down

0 comments on commit f93bc01

Please sign in to comment.