def delete(self, request):
"""
Take the user object from the request and call the 'delete' method on it if it exists in the DB.
If this succeeds then we can report a success.
:param request:
:param args:
:param kwargs:
:return: Serialised JSON Response Object to indicate the resource has been created
"""
stdlogger.debug("Hitting HTTP DELETE account view")
user_email = request.user.email
try:
stdlogger.debug("Deleting this user object")
request.user.delete()
except (IntegrityError, InternalError, DataError, DatabaseError):
# The chances of this happening are slim to none! And this line of code should never happen. So we really
# need to tell the other system we are not capable of creating the resource.
raise DatabaseFailureException
context = {'account': user_email, 'deleted': 'success'}
json_context = JSONRenderer().render(context)
return Response(data=json_context, status=status.HTTP_201_CREATED,)
评论列表
文章目录