#31 API DELETE
* adds support for DELETE method for all relevant objects * improves get_obj_from_db functionality * drops custom compensation logic for get_obj_from_db due to improvement of base method
This commit is contained in:
@@ -79,7 +79,7 @@ class AbstractAPIViewV1(AbstractAPIView):
|
||||
id (str): The entries id
|
||||
|
||||
Returns:
|
||||
|
||||
response (JsonResponse)
|
||||
"""
|
||||
try:
|
||||
body = request.body.decode("utf-8")
|
||||
@@ -89,6 +89,27 @@ class AbstractAPIViewV1(AbstractAPIView):
|
||||
return self.return_error_response(e, 500)
|
||||
return JsonResponse({"id": updated_id})
|
||||
|
||||
def delete(self, request: HttpRequest, id=None):
|
||||
""" Handles a DELETE request
|
||||
|
||||
Args:
|
||||
request (HttpRequest): The incoming request
|
||||
id (str): The object's id
|
||||
|
||||
Returns:
|
||||
response (JsonResponse)
|
||||
"""
|
||||
|
||||
try:
|
||||
success = self.serializer.delete_entry(id, self.user)
|
||||
except Exception as e:
|
||||
return self.return_error_response(e, 500)
|
||||
return JsonResponse(
|
||||
{
|
||||
"success": success,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class InterventionAPIViewV1(AbstractAPIViewV1):
|
||||
serializer = InterventionAPISerializerV1
|
||||
|
||||
Reference in New Issue
Block a user