diff --git a/backend/api/serializers.py b/backend/api/serializers.py index 6bf853f..5dc6c7d 100644 --- a/backend/api/serializers.py +++ b/backend/api/serializers.py @@ -77,15 +77,16 @@ class Meta: many = True def validate(self, data): - print( - [ - data["soft_skill_test_matching"][i].soft_skill_name - for i in data["soft_skill_test_matching"] - ] - ) + print(data["about_me"]) return data def get_matches(self, instance): + headers = self.context["request"].headers + print(headers) + if "Hide-Matches" in headers: + if headers["Hide-Matches"] == "true": + return "Hide-Matches set to true" + HARD_SKILL_PERCENTAGE = float(os.environ["HARD_SKILL_PERCENTAGE"]) SOFT_SKILL_PERCENTAGE = float(os.environ["SOFT_SKILL_PERCENTAGE"]) FREE_TEXT_PERCENTAGE = float(os.environ["FREE_TEXT_PERCENTAGE"]) @@ -243,6 +244,12 @@ class Meta: many = True def get_matches(self, instance): + headers = self.context["request"].headers + print(headers) + if "Hide-Matches" in headers: + if headers["Hide-Matches"] == "true": + return "Hide-Matches set to true" + HARD_SKILL_PERCENTAGE = float(os.environ["HARD_SKILL_PERCENTAGE"]) SOFT_SKILL_PERCENTAGE = float(os.environ["SOFT_SKILL_PERCENTAGE"]) FREE_TEXT_PERCENTAGE = float(os.environ["FREE_TEXT_PERCENTAGE"]) diff --git a/backend/api/views.py b/backend/api/views.py index 0df5e27..fc6638e 100644 --- a/backend/api/views.py +++ b/backend/api/views.py @@ -3,10 +3,7 @@ from rest_framework.response import Response from rest_framework.views import APIView from rest_framework import mixins -from drf_spectacular.utils import ( - extend_schema_view, - extend_schema, -) +from drf_spectacular.utils import extend_schema_view, extend_schema, OpenApiParameter import json from api import serializers as model_serializers @@ -290,6 +287,21 @@ def post(self, request): return Response(response_payload, status=status_code) +@extend_schema_view( + retrieve=extend_schema( + summary="Retrieve information for a candidate", + description=""" + Provide the candidate id in the url parameter and this will retrieve all the information associated with the candidate. + + Optional: + Hide-Matches: bool + If true, will not return the matches for faster loading + """, + parameters=[ + OpenApiParameter("Hide-Matches", bool, OpenApiParameter.HEADER), + ], + ), +) class CandidatesViewSet(viewsets.ModelViewSet): queryset = model_serializers.Candidates.objects.all() serializer_class = model_serializers.CandidatesSerializer @@ -300,6 +312,22 @@ class AvailableCompanyDomainsViewSet(viewsets.ModelViewSet): serializer_class = model_serializers.AvailableCompanyDomainsSerializer +@extend_schema_view( + retrieve=extend_schema( + summary="Retrieve information for a job", + description=""" + Provide the job id in the url parameter and this will retrieve all the information associated with the job. + + Optional: + Hide-Matches: bool + If true, will not return the matches for faster loading + """, + parameters=[ + OpenApiParameter("job_id", int, OpenApiParameter.PATH, required=True), + OpenApiParameter("Hide-Matches", bool, OpenApiParameter.HEADER), + ], + ), +) class JobsViewSet(viewsets.ModelViewSet): queryset = model_serializers.Jobs.objects.all() serializer_class = model_serializers.JobsSerializer