Use proper cornice service registration, for API batch execute etc.
This commit is contained in:
parent
a721ec4a43
commit
1570871884
|
@ -31,7 +31,7 @@ import six
|
||||||
from rattail.time import localtime
|
from rattail.time import localtime
|
||||||
from rattail.util import load_object
|
from rattail.util import load_object
|
||||||
|
|
||||||
from cornice import resource
|
from cornice import resource, Service
|
||||||
|
|
||||||
from tailbone.api import APIMasterView2 as APIMasterView
|
from tailbone.api import APIMasterView2 as APIMasterView
|
||||||
|
|
||||||
|
@ -213,25 +213,27 @@ class APIBatchView(APIBatchMixin, APIMasterView):
|
||||||
if cls.supports_toggle_complete:
|
if cls.supports_toggle_complete:
|
||||||
|
|
||||||
# mark complete
|
# mark complete
|
||||||
config.add_route('{}.mark_complete'.format(route_prefix), '{}/{{uuid}}/mark-complete'.format(object_url_prefix))
|
mark_complete = Service(name='{}.mark_complete'.format(route_prefix),
|
||||||
config.add_view(cls, attr='mark_complete', route_name='{}.mark_complete'.format(route_prefix),
|
path='{}/{{uuid}}/mark-complete'.format(object_url_prefix))
|
||||||
permission='{}.edit'.format(permission_prefix),
|
mark_complete.add_view('POST', 'mark_complete', klass=cls,
|
||||||
renderer='json')
|
permission='{}.edit'.format(permission_prefix))
|
||||||
|
config.add_cornice_service(mark_complete)
|
||||||
|
|
||||||
# mark incomplete
|
# mark incomplete
|
||||||
config.add_route('{}.mark_incomplete'.format(route_prefix), '{}/{{uuid}}/mark-incomplete'.format(object_url_prefix))
|
mark_incomplete = Service(name='{}.mark_incomplete'.format(route_prefix),
|
||||||
config.add_view(cls, attr='mark_incomplete', route_name='{}.mark_incomplete'.format(route_prefix),
|
path='{}/{{uuid}}/mark-incomplete'.format(object_url_prefix))
|
||||||
permission='{}.edit'.format(permission_prefix),
|
mark_incomplete.add_view('POST', 'mark_incomplete', klass=cls,
|
||||||
renderer='json')
|
permission='{}.edit'.format(permission_prefix))
|
||||||
|
config.add_cornice_service(mark_incomplete)
|
||||||
|
|
||||||
if cls.supports_execute:
|
if cls.supports_execute:
|
||||||
|
|
||||||
# execute
|
# execute batch
|
||||||
config.add_route('{}.execute'.format(route_prefix), '{}/{{uuid}}/execute'.format(object_url_prefix),
|
execute = Service(name='{}.execute'.format(route_prefix),
|
||||||
request_method=('OPTIONS', 'POST'))
|
path='{}/{{uuid}}/execute'.format(object_url_prefix))
|
||||||
config.add_view(cls, attr='execute', route_name='{}.execute'.format(route_prefix),
|
execute.add_view('POST', 'execute', klass=cls,
|
||||||
permission='{}.execute'.format(permission_prefix),
|
permission='{}.execute'.format(permission_prefix))
|
||||||
renderer='json')
|
config.add_cornice_service(execute)
|
||||||
|
|
||||||
|
|
||||||
# TODO: deprecate / remove this
|
# TODO: deprecate / remove this
|
||||||
|
|
Loading…
Reference in a new issue