Skip to content

Commit

Permalink
Update logic for updating offer - if status is expired user cant chan…
Browse files Browse the repository at this point in the history
…ge the status of an offer
  • Loading branch information
DEENUU1 committed Dec 9, 2023
1 parent 10bef8c commit 8ca2166
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions company/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ def create(self, request):

return Response(serializer.data, status=status.HTTP_201_CREATED)

# elif


else:
return Response({"info": "You have reached the limit of offers"}, status=status.HTTP_400_BAD_REQUEST)
else:
Expand All @@ -87,6 +84,15 @@ def partial_update(self, request, pk=None):
if offer.is_expired:
return Response({"info": "Offer is expired"}, status=status.HTTP_400_BAD_REQUEST)

new_status = request.data.get("status", None)
if new_status and offer.status == "EXPIRED":
return Response(
{
"info": "You can't change the status for this job offer, it's already expired"
},
status=status.HTTP_400_BAD_REQUEST
)

serializer = JobOfferSerializer(offer, data=request.data, partial=True)
serializer.is_valid(raise_exception=True)
serializer.save()
Expand Down

0 comments on commit 8ca2166

Please sign in to comment.