From f93bc01d6e20ace3295bba673fa6139e4e65113c Mon Sep 17 00:00:00 2001 From: Alexander Orvik Date: Tue, 27 Aug 2024 14:57:09 +0200 Subject: [PATCH] fix(admissions): send email when applicant interview is moved --- admissions/schema.py | 5 +++- admissions/utils.py | 65 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/admissions/schema.py b/admissions/schema.py index dd446404..67849317 100644 --- a/admissions/schema.py +++ b/admissions/schema.py @@ -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, @@ -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) diff --git a/admissions/utils.py b/admissions/utils.py index f01f31da..eddc2bb6 100644 --- a/admissions/utils.py +++ b/admissions/utils.py @@ -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! +
+ %(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, + } + ) + + 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)