Skip to content

Commit

Permalink
Support serialization on UpdateAPI w/o DetailAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
stevelacey committed Jul 13, 2022
1 parent fd8da79 commit 89c03a5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
3 changes: 3 additions & 0 deletions worf/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def load_serializer(self):
raise SerializerError(f"Invalid fields: {invalid_fields}")
raise e # pragma: no cover

def serialize(self):
return self.load_serializer().dump(self.get_instance())


class SerializerOptions(marshmallow.SchemaOpts):
def __init__(self, meta, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion worf/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def render_to_response(self, data=None, status_code=200):
return render_response(self.request, data, status_code)


class AbstractBaseAPI(APIResponse, SerializeModels, ValidateFields):
class AbstractBaseAPI(SerializeModels, ValidateFields, APIResponse):
model = None
permissions = []
payload_key = None
Expand Down
3 changes: 0 additions & 3 deletions worf/views/detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ def get_serializer(self):
return self.detail_serializer(**self.get_serializer_kwargs())
return super().get_serializer()

def serialize(self):
return self.load_serializer().dump(self.get_instance())


class DetailUpdateAPI(UpdateAPI, DetailAPI):
pass

0 comments on commit 89c03a5

Please sign in to comment.