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

remove possibility to set to called before repri for gangs #1637

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
8 changes: 7 additions & 1 deletion backend/samfundet/models/recruitment.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@ def save(self, *args: tuple, **kwargs: dict) -> None: # noqa: C901
)
if shared_interview:
self.interview = shared_interview.interview

super().save(*args, **kwargs)

def get_total_interviews(self) -> int:
Expand Down Expand Up @@ -426,6 +425,13 @@ def update_applicant_state(self) -> None:
application.applicant_state = RecruitmentApplicantStates.NOT_WANTED
application.save()

def clean_set_recruiter_status(self, status: RecruitmentStatusChoices) -> RecruitmentStatusChoices:
if status not in [RecruitmentStatusChoices.CALLED_AND_ACCEPTED, RecruitmentStatusChoices.CALLED_AND_REJECTED]:
return status
if timezone.now() < self.recruitment.reprioritization_deadline_for_groups:
return self.recruiter_status
return status


class RecruitmentInterviewAvailability(CustomBaseModel):
"""This models all possible times for interviews for the given recruitment.
Expand Down
15 changes: 13 additions & 2 deletions backend/samfundet/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,8 +971,15 @@ def test_update_application_recruiter_priority_gang(


def test_update_application_recruiter_status_gang(
fixture_rest_client: APIClient, fixture_user: User, fixture_user2: User, fixture_recruitment_application: RecruitmentApplication
fixture_rest_client: APIClient,
fixture_recruitment: Recruitment,
fixture_user: User,
fixture_user2: User,
fixture_recruitment_application: RecruitmentApplication,
):
# Need to find a way to adjust timezone or set the times of recruitment to now
# To able to set recruitment to now due to the fields are required to be in future

### Arrange ###
fixture_rest_client.force_authenticate(user=fixture_user2)
fixture_recruitment_application.user = fixture_user2
Expand Down Expand Up @@ -1047,7 +1054,11 @@ def test_update_application_recruiter_priority_position(


def test_update_application_recruiter_status_position(
fixture_rest_client: APIClient, fixture_user: User, fixture_user2: User, fixture_recruitment_application: RecruitmentApplication
fixture_rest_client: APIClient,
fixture_recruitment: Recruitment,
fixture_user: User,
fixture_user2: User,
fixture_recruitment_application: RecruitmentApplication,
):
### Arrange ###
fixture_rest_client.force_authenticate(user=fixture_user2)
Expand Down
4 changes: 2 additions & 2 deletions backend/samfundet/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ def put(self, request: Request, pk: int) -> Response:
if 'recruiter_priority' in update_serializer.data:
application.recruiter_priority = update_serializer.data['recruiter_priority']
if 'recruiter_status' in update_serializer.data:
application.recruiter_status = update_serializer.data['recruiter_status']
application.recruiter_status = application.clean_set_recruiter_status(update_serializer.data['recruiter_status'])
application.save()
applications = RecruitmentApplication.objects.filter(
recruitment_position__gang=application.recruitment_position.gang,
Expand All @@ -1097,7 +1097,7 @@ def put(self, request: Request, pk: int) -> Response:
if 'recruiter_priority' in update_serializer.data:
application.recruiter_priority = update_serializer.data['recruiter_priority']
if 'recruiter_status' in update_serializer.data:
application.recruiter_status = update_serializer.data['recruiter_status']
application.recruiter_status = application.clean_set_recruiter_status(update_serializer.data['recruiter_status'])
application.save()
application.update_applicant_state()
applications = RecruitmentApplication.objects.filter(
Expand Down