Refactor API views a bit for sake of running as separate service
also add "proper" (sic) permission checks
This commit is contained in:
parent
9b61b05155
commit
fec8ba28e2
5 changed files with 35 additions and 15 deletions
|
@ -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__)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue