Add support for "toggle complete" for batch API
This commit is contained in:
parent
bd09acd0fd
commit
afdd294c60
3 changed files with 92 additions and 16 deletions
|
@ -86,12 +86,23 @@ class APIMasterView(APIView):
|
|||
return cls.get_route_prefix()
|
||||
|
||||
@classmethod
|
||||
def get_url_prefix(cls):
|
||||
def get_collection_url_prefix(cls):
|
||||
"""
|
||||
Returns a prefix which (by default) applies to all URLs provided by
|
||||
this view class.
|
||||
Returns a prefix which (by default) applies to all "collection" URLs
|
||||
provided by this view class.
|
||||
"""
|
||||
prefix = getattr(cls, 'url_prefix', None)
|
||||
prefix = getattr(cls, 'collection_url_prefix', None)
|
||||
if prefix:
|
||||
return prefix
|
||||
return '/{}'.format(cls.get_route_prefix())
|
||||
|
||||
@classmethod
|
||||
def get_object_url_prefix(cls):
|
||||
"""
|
||||
Returns a prefix which (by default) applies to all "object" URLs
|
||||
provided by this view class.
|
||||
"""
|
||||
prefix = getattr(cls, 'object_url_prefix', None)
|
||||
if prefix:
|
||||
return prefix
|
||||
return '/{}'.format(cls.get_route_prefix())
|
||||
|
@ -271,13 +282,19 @@ class APIMasterView(APIView):
|
|||
|
||||
return context
|
||||
|
||||
def get_object(self, uuid=None):
|
||||
if not uuid:
|
||||
uuid = self.request.matchdict['uuid']
|
||||
|
||||
obj = self.Session.query(self.get_model_class()).get(uuid)
|
||||
if obj:
|
||||
return obj
|
||||
|
||||
raise self.notfound()
|
||||
|
||||
def _get(self, obj=None, uuid=None):
|
||||
if not obj:
|
||||
if not uuid:
|
||||
uuid = self.request.matchdict['uuid']
|
||||
obj = self.Session.query(self.get_model_class()).get(uuid)
|
||||
if not obj:
|
||||
raise self.notfound()
|
||||
obj = self.get_object(uuid=uuid)
|
||||
key = self.get_object_key()
|
||||
normal = self.normalize(obj)
|
||||
return {key: normal, 'data': normal}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue