Skip to content

Commit

Permalink
Delete partial_update method from OfferViewSet
Browse files Browse the repository at this point in the history
  • Loading branch information
DEENUU1 committed Dec 20, 2023
1 parent 4961488 commit 0370dd4
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions offer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,30 +160,6 @@ def update(self, request, pk=None):
serializer.save()
return Response(serializer.data)

def partial_update(self, request, pk=None):
offer = JobOffer.objects.get(pk=pk)

if offer.company.user != request.user:
return Response({"info": "You do not have permission to update this offer"},
status=status.HTTP_403_FORBIDDEN)

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()
return Response(serializer.data)

def destroy(self, request, pk=None):
offer = JobOffer.objects.get(pk=pk)

Expand Down

0 comments on commit 0370dd4

Please sign in to comment.