Skip to content

Commit

Permalink
feat: Update method for Objective model
Browse files Browse the repository at this point in the history
  • Loading branch information
avinogrado authored and the-homeless-god committed Aug 31, 2024
1 parent fc84058 commit c473751
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions application/backend/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,23 @@ def destroy(self,request,*args,**kwargs):
except IndexError:
logging.exception("Index out of range")
return Response(status=status.HTTP_404_NOT_FOUND)

def update(self, request, *args, **kwargs):
logging.info(request)
try:
details = Objective.objects.get(id=kwargs['pk'])
logging.info('Object found')
serializer = Objective_Serializer(
details, data=request.data, partial=True)
serializer.is_valid()
logging.info('Data is valid')
serializer.save()
logging.info('Changes have been applied',serializer.data)
return Response(serializer.data,status=status.HTTP_201_CREATED)
except ValidationError:
logging.exception('Data is not valid')
return Response(serializer.errors,status=status.HTTP_400_BAD_REQUEST)
except Employee.DoesNotExist:
logging.exception('Object not found')
return Response(status=status.HTTP_404_NOT_FOUND)

0 comments on commit c473751

Please sign in to comment.