From 363aa26413eb854d8b90ff9baf2dd58ea6beb8b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=A7=D0=B5?= <39742182+Dmi4er4@users.noreply.github.com> Date: Mon, 24 Jun 2024 12:29:29 +0300 Subject: [PATCH] Interview fix (#852) * script fix * test fix * update --- apps/admission/filters.py | 3 +- apps/admission/services.py | 19 +++++---- .../templates/admission/interview_detail.html | 1 + .../templates/admission/interview_list.html | 9 +++- apps/admission/tests/test_services.py | 2 +- apps/admission/views.py | 42 ++++++++++++------- .../admission/interview_invitation_list.html | 28 ++++++------- .../admission/send_interview_invitations.html | 12 +++--- 8 files changed, 69 insertions(+), 47 deletions(-) diff --git a/apps/admission/filters.py b/apps/admission/filters.py index cc733d1e0..9431d2776 100644 --- a/apps/admission/filters.py +++ b/apps/admission/filters.py @@ -172,6 +172,7 @@ class InvitationCreateInterviewStreamFilter(InterviewStreamFilter): number_of_misses = django_filters.ChoiceFilter( label=_("Applicant number of missed interviews"), choices=ApplicantMisses ) + last_name = django_filters.CharFilter(label=_("Last Name")) @property def form(self): @@ -182,7 +183,7 @@ def form(self): self._form.helper.layout = Layout( Row( Div("campaign", css_class="col-xs-3"), Div("section", css_class="col-xs-3"), - Div("format", css_class="col-xs-3")), + Div("format", css_class="col-xs-3"), Div("last_name", css_class="col-xs-3")), Row( Div("track", css_class="col-xs-3"), Div("way_to_interview", css_class="col-xs-3"), Div("number_of_misses", css_class="col-xs-3"), diff --git a/apps/admission/services.py b/apps/admission/services.py index 13b23396b..61db4dd70 100644 --- a/apps/admission/services.py +++ b/apps/admission/services.py @@ -73,7 +73,7 @@ def get_ongoing_interview_streams() -> models.QuerySet[InterviewStream]: def get_applicants_for_invitation( - *, campaign: Campaign, section: str, format=None, track=None, way_to_interview=None, + *, campaign: Campaign, section: str, format=None, last_name=None, track=None, way_to_interview=None, number_of_misses=None ) -> models.QuerySet[Applicant]: """ @@ -98,15 +98,19 @@ def get_applicants_for_invitation( .values("applicant_id")) format_filter = Q() - if format is not None: + if format: format_filter = Q(interview_format=format) | Q(interview_format=ApplicantInterviewFormats.ANY) + last_name_filter = Q() + if last_name: + last_name_filter = Q(last_name__icontains=last_name) + track_filter = Q() - if track is not None: - track_filter = Q(new_track=(track=="alternative")) + if track: + track_filter = Q(new_track=(track == "alternative")) way_filter = Q() - if way_to_interview is not None: + if way_to_interview: if way_to_interview == "exam": way_filter = Q(status=ApplicantStatuses.PASSED_EXAM) elif way_to_interview == "olympiad": @@ -116,9 +120,8 @@ def get_applicants_for_invitation( else: raise ValueError(f"Unsupported value {way_to_interview}") - miss_filter = Q() - if number_of_misses is not None: + if number_of_misses or number_of_misses == 0: if number_of_misses in range(0, 4): way_filter = Q(miss_count=number_of_misses) elif number_of_misses == 4: @@ -132,6 +135,7 @@ def get_applicants_for_invitation( track_filter, way_filter, miss_filter, + last_name_filter, campaign=campaign, status__in=ApplicantStatuses.RIGHT_BEFORE_INTERVIEW, ) @@ -253,7 +257,6 @@ def get_streams( return {stream: slots for stream, slots in bucket.items() if stream.slots_free_count != 0} - # TODO: change exception type class InterviewCreateError(APIException): pass diff --git a/apps/admission/templates/admission/interview_detail.html b/apps/admission/templates/admission/interview_detail.html index 560b8d4d7..185dea613 100644 --- a/apps/admission/templates/admission/interview_detail.html +++ b/apps/admission/templates/admission/interview_detail.html @@ -26,6 +26,7 @@

{{ applicant.full_name }}{% if request.user.is_curator %}
Секция: {{ interview.get_section_display }}
Статус собеседования: {{ interview.get_status_display|default_if_none:"<не указан>" }}
+ Формат собеседования: {{ interview.slot.stream.get_format_display|default_if_none:"<не указан>" }}