Пример #1
0
 def patch(self, *args, **kwargs):
     computed_schema = self.schema(partial=True)
     try:
         data, errors = computed_schema.load(request.get_json())
     except marshmallow.ValidationError as e:
         return response.JsonApiErrorResponse.from_marshmallow_errors(
             e.messages)
     else:
         if errors:
             return response.JsonApiErrorResponse.from_marshmallow_errors(
                 errors)
         else:
             resource = self.update(self.resource_id, data)
             if resource:
                 return response.JsonApiResponse(
                     computed_schema.dump(resource).data)
             else:
                 return response.EmptyResponse()
Пример #2
0
 def delete(self, *args, **kwargs):
     self.destroy(self.resource_id)
     return response.EmptyResponse()