Add new "master" API view class; refactor products and batches to use it
This commit is contained in:
parent
df00dd600a
commit
113c0af49d
8 changed files with 183 additions and 90 deletions
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2019 Lance Edgar
|
||||
# Copyright © 2010-2020 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -33,7 +33,7 @@ from rattail.util import load_object
|
|||
|
||||
from cornice import resource
|
||||
|
||||
from tailbone.api import APIMasterView
|
||||
from tailbone.api import APIMasterView2 as APIMasterView
|
||||
|
||||
|
||||
class APIBatchMixin(object):
|
||||
|
@ -197,6 +197,7 @@ class APIBatchView(APIBatchMixin, APIMasterView):
|
|||
|
||||
@classmethod
|
||||
def defaults(cls, config):
|
||||
cls._defaults(config)
|
||||
cls._batch_defaults(config)
|
||||
|
||||
@classmethod
|
||||
|
@ -206,14 +207,6 @@ class APIBatchView(APIBatchMixin, APIMasterView):
|
|||
collection_url_prefix = cls.get_collection_url_prefix()
|
||||
object_url_prefix = cls.get_object_url_prefix()
|
||||
|
||||
# primary / typical API
|
||||
resource.add_view(cls.collection_get, permission='{}.list'.format(permission_prefix))
|
||||
resource.add_view(cls.collection_post, permission='{}.create'.format(permission_prefix))
|
||||
resource.add_view(cls.get, permission='{}.view'.format(permission_prefix))
|
||||
batch_resource = resource.add_resource(cls, collection_path=collection_url_prefix,
|
||||
path='{}/{{uuid}}'.format(object_url_prefix))
|
||||
config.add_cornice_resource(batch_resource)
|
||||
|
||||
if cls.supports_toggle_complete:
|
||||
|
||||
# mark complete
|
||||
|
@ -299,6 +292,7 @@ class APIBatchRowView(APIBatchMixin, APIMasterView):
|
|||
|
||||
@classmethod
|
||||
def defaults(cls, config):
|
||||
cls._defaults(config)
|
||||
cls._batch_row_defaults(config)
|
||||
|
||||
@classmethod
|
||||
|
@ -308,14 +302,6 @@ class APIBatchRowView(APIBatchMixin, APIMasterView):
|
|||
collection_url_prefix = cls.get_collection_url_prefix()
|
||||
object_url_prefix = cls.get_object_url_prefix()
|
||||
|
||||
resource.add_view(cls.collection_get, permission='{}.view'.format(permission_prefix))
|
||||
resource.add_view(cls.get, permission='{}.view'.format(permission_prefix))
|
||||
if cls.editable:
|
||||
resource.add_view(cls.post, permission='{}.edit'.format(permission_prefix))
|
||||
rows_resource = resource.add_resource(cls, collection_path=collection_url_prefix,
|
||||
path='{}/{{uuid}}'.format(object_url_prefix))
|
||||
config.add_cornice_resource(rows_resource)
|
||||
|
||||
if cls.supports_quick_entry:
|
||||
|
||||
# quick entry
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue