Skip to content

Commit

Permalink
fix formating
Browse files Browse the repository at this point in the history
  • Loading branch information
magsyg committed Nov 5, 2024
1 parent 33430af commit 8712910
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 36 deletions.
10 changes: 7 additions & 3 deletions backend/samfundet/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions backend/samfundet/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) => {
Expand All @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ export type RecruitmentPositionOrganizedApplicationsDto = {
rejected: RecruitmentApplicationDto[];
accepted: RecruitmentApplicationDto[];
hardtoget: RecruitmentApplicationDto[];
}
};

export type RecruitmentApplicationDto = {
id: string;
Expand Down

0 comments on commit 8712910

Please sign in to comment.