Refactor API views a bit for sake of running as separate service

also add "proper" (sic) permission checks
This commit is contained in:
Lance Edgar 2018-11-03 18:55:26 -05:00
parent 9b61b05155
commit fec8ba28e2
5 changed files with 35 additions and 15 deletions

View file

@ -28,12 +28,12 @@ from __future__ import unicode_literals, absolute_import
from rattail.db import model
from cornice.resource import resource
from cornice.resource import resource, view
from tailbone.api import APIMasterView
@resource(collection_path='/api/customers', path='/api/customer/{uuid}')
@resource(collection_path='/customers', path='/customer/{uuid}')
class CustomerView(APIMasterView):
model_class = model.Customer
@ -44,6 +44,14 @@ class CustomerView(APIMasterView):
'name': customer.name,
}
@view(permission='customers.list')
def collection_get(self):
return self._collection_get()
@view(permission='customers.view')
def get(self):
return self._get()
def includeme(config):
config.scan(__name__)