Refactor all API views thus far, to use new v2 master

This commit is contained in:
Lance Edgar 2020-03-01 17:17:54 -06:00
parent 113c0af49d
commit c55830e533
4 changed files with 28 additions and 80 deletions

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2019 Lance Edgar
# Copyright © 2010-2020 Lance Edgar
#
# This file is part of Rattail.
#
@ -30,15 +30,16 @@ import six
from rattail.db import model
from cornice.resource import resource, view
from tailbone.api import APIMasterView
from tailbone.api import APIMasterView2 as APIMasterView
@resource(collection_path='/customers', path='/customer/{uuid}')
class CustomerView(APIMasterView):
"""
API views for Customer data
"""
model_class = model.Customer
collection_url_prefix = '/customers'
object_url_prefix = '/customer'
def normalize(self, customer):
return {
@ -48,22 +49,6 @@ class CustomerView(APIMasterView):
'name': customer.name,
}
@view(permission='customers.list')
def collection_get(self):
return self._collection_get()
@view(permission='customers.create')
def collection_post(self):
return self._collection_post()
@view(permission='customers.view')
def get(self):
return self._get()
@view(permission='customers.edit')
def post(self):
return self._post()
def includeme(config):
config.scan(__name__)
CustomerView.defaults(config)