From 8712910c6f8fecb0a465273b306befff84de07a2 Mon Sep 17 00:00:00 2001 From: magsyg Date: Tue, 5 Nov 2024 23:03:06 +0100 Subject: [PATCH] fix formating --- backend/samfundet/serializers.py | 10 ++-- backend/samfundet/views.py | 1 + .../RecruitmentPositionOverviewPage.tsx | 46 ++++++------------- frontend/src/api.ts | 2 +- frontend/src/dto.ts | 2 +- 5 files changed, 25 insertions(+), 36 deletions(-) diff --git a/backend/samfundet/serializers.py b/backend/samfundet/serializers.py index 96bb7f5b5..ec2e05019 100644 --- a/backend/samfundet/serializers.py +++ b/backend/samfundet/serializers.py @@ -1094,6 +1094,7 @@ def update(self, instance: RecruitmentApplication, validated_data: dict) -> Recr def get_application_count(self, application: RecruitmentApplication) -> int: return application.user.applications.filter(recruitment=application.recruitment).count() + class RecruitmentPositionOrganizedApplications(CustomBaseSerializer): applicationSerializer = RecruitmentApplicationForGangSerializer unprocessed = serializers.SerializerMethodField(method_name='get_unprocessed', read_only=True) @@ -1113,19 +1114,22 @@ def get_unprocessed(self, instance: RecruitmentPosition): def get_withdrawn(self, instance: RecruitmentPosition): withdrawn = instance.applications.filter(withdrawn=True) return self.applicationSerializer(withdrawn, many=True).data - + def get_rejected(self, instance: RecruitmentPosition): - rejected = instance.applications.filter(withdrawn=False, recruiter_status__in=[RecruitmentStatusChoices.AUTOMATIC_REJECTION, RecruitmentStatusChoices.REJECTION]) + rejected = instance.applications.filter( + withdrawn=False, recruiter_status__in=[RecruitmentStatusChoices.AUTOMATIC_REJECTION, RecruitmentStatusChoices.REJECTION] + ) return self.applicationSerializer(rejected, many=True).data def get_accepted(self, instance: RecruitmentPosition): accepted = instance.applications.filter(withdrawn=False, recruiter_status=RecruitmentStatusChoices.CALLED_AND_ACCEPTED) return self.applicationSerializer(accepted, many=True).data - + def get_hardtoget(self, instance: RecruitmentPosition): hardtoget = instance.applications.filter(withdrawn=False, recruiter_status=RecruitmentStatusChoices.CALLED_AND_REJECTED) return self.applicationSerializer(hardtoget, many=True).data + class RecruitmentApplicationUpdateForGangSerializer(serializers.Serializer): recruiter_priority = serializers.ChoiceField(choices=RecruitmentPriorityChoices.choices, required=False) recruiter_status = serializers.ChoiceField(choices=RecruitmentStatusChoices.choices, required=False) diff --git a/backend/samfundet/views.py b/backend/samfundet/views.py index 9287a0bbb..f9ae11a69 100644 --- a/backend/samfundet/views.py +++ b/backend/samfundet/views.py @@ -1053,6 +1053,7 @@ def get(self, request: Request, pk: int) -> Response: serializer = self.serializer_class(position) return Response(serializer.data, status=status.HTTP_200_OK) + class RecruitmentApplicationForPositionUpdateStateView(APIView): permission_classes = [IsAuthenticated] serializer_class = RecruitmentApplicationUpdateForGangSerializer diff --git a/frontend/src/PagesAdmin/RecruitmentPositionOverviewPage/RecruitmentPositionOverviewPage.tsx b/frontend/src/PagesAdmin/RecruitmentPositionOverviewPage/RecruitmentPositionOverviewPage.tsx index 3af1c196c..3f37b74e4 100644 --- a/frontend/src/PagesAdmin/RecruitmentPositionOverviewPage/RecruitmentPositionOverviewPage.tsx +++ b/frontend/src/PagesAdmin/RecruitmentPositionOverviewPage/RecruitmentPositionOverviewPage.tsx @@ -4,7 +4,11 @@ import { useNavigate, useParams } from 'react-router-dom'; import { toast } from 'react-toastify'; import { Button, RecruitmentApplicantsStatus } from '~/Components'; import { Text } from '~/Components/Text/Text'; -import { getRecruitmentApplicationsForGang, getRecruitmentPositionOrganizedApplications, updateRecruitmentApplicationStateForPosition } from '~/api'; +import { + getRecruitmentApplicationsForGang, + getRecruitmentPositionOrganizedApplications, + updateRecruitmentApplicationStateForPosition, +} from '~/api'; import type { RecruitmentApplicationDto, RecruitmentApplicationStateDto } from '~/dto'; import { useTitle } from '~/hooks'; import { STATUS } from '~/http_status_codes'; @@ -35,21 +39,11 @@ export function RecruitmentPositionOverviewPage() { } getRecruitmentPositionOrganizedApplications(positionId) .then((response) => { - setRecruitmentApplicants( - response.data.unprocessed - ); - setWithdrawnApplicants( - response.data.withdrawn - ); - setHardtogetApplicants( - response.data.hardtoget - ); - setRejectedApplicants( - response.data.rejected - ); - setAcceptedApplicants( - response.data.accepted - ); + setRecruitmentApplicants(response.data.unprocessed); + setWithdrawnApplicants(response.data.withdrawn); + setHardtogetApplicants(response.data.hardtoget); + setRejectedApplicants(response.data.rejected); + setAcceptedApplicants(response.data.accepted); setShowSpinner(false); }) .catch((data) => { @@ -68,21 +62,11 @@ export function RecruitmentPositionOverviewPage() { positionId && updateRecruitmentApplicationStateForPosition(id, data) .then((response) => { - setRecruitmentApplicants( - response.data.unprocessed - ); - setWithdrawnApplicants( - response.data.withdrawn - ); - setHardtogetApplicants( - response.data.hardtoget - ); - setRejectedApplicants( - response.data.rejected - ); - setAcceptedApplicants( - response.data.accepted - ); + setRecruitmentApplicants(response.data.unprocessed); + setWithdrawnApplicants(response.data.withdrawn); + setHardtogetApplicants(response.data.hardtoget); + setRejectedApplicants(response.data.rejected); + setAcceptedApplicants(response.data.accepted); setShowSpinner(false); }) .catch((data) => { diff --git a/frontend/src/api.ts b/frontend/src/api.ts index dae569074..2e47cdff6 100644 --- a/frontend/src/api.ts +++ b/frontend/src/api.ts @@ -828,7 +828,7 @@ export async function getRecruitmentPositionOrganizedApplications( reverse({ pattern: ROUTES.backend.samfundet__recruitment_position_organized_applications, urlParams: { - pk: positionId + pk: positionId, }, }); return await axios.get(url, { withCredentials: true }); diff --git a/frontend/src/dto.ts b/frontend/src/dto.ts index 53d9da5e2..be99867cb 100644 --- a/frontend/src/dto.ts +++ b/frontend/src/dto.ts @@ -502,7 +502,7 @@ export type RecruitmentPositionOrganizedApplicationsDto = { rejected: RecruitmentApplicationDto[]; accepted: RecruitmentApplicationDto[]; hardtoget: RecruitmentApplicationDto[]; -} +}; export type RecruitmentApplicationDto = { id: string;