diff --git a/tailbone/api/customers.py b/tailbone/api/customers.py index 2e0a9d4c..fdd2c18e 100644 --- a/tailbone/api/customers.py +++ b/tailbone/api/customers.py @@ -46,6 +46,7 @@ class CustomerView(APIMasterView): 'uuid': customer.uuid, '_str': six.text_type(customer), 'id': customer.id, + 'number': customer.number, 'name': customer.name, } diff --git a/tailbone/api/master.py b/tailbone/api/master.py index 775292bc..27030f5b 100644 --- a/tailbone/api/master.py +++ b/tailbone/api/master.py @@ -129,6 +129,10 @@ class APIMasterView(APIView): def make_sort_spec(self): + # we prefer a "native sort" + if self.request.GET.has_key('nativeSort'): + return json.loads(self.request.GET.getone('nativeSort')) + # these params are based on 'vuetable-2' # https://www.vuetable.com/guide/sorting.html#initial-sorting-order if 'sort' in self.request.params: diff --git a/tailbone/api/people.py b/tailbone/api/people.py new file mode 100644 index 00000000..bb8dd883 --- /dev/null +++ b/tailbone/api/people.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8; -*- +################################################################################ +# +# Rattail -- Retail Software Framework +# Copyright © 2010-2021 Lance Edgar +# +# This file is part of Rattail. +# +# Rattail is free software: you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. +# +# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# Rattail. If not, see . +# +################################################################################ +""" +Tailbone Web API - Person Views +""" + +from __future__ import unicode_literals, absolute_import + +import six + +from rattail.db import model + +from tailbone.api import APIMasterView2 as APIMasterView + + +class PersonView(APIMasterView): + """ + API views for Person data + """ + model_class = model.Person + permission_prefix = 'people' + collection_url_prefix = '/people' + object_url_prefix = '/person' + + def normalize(self, person): + return { + 'uuid': person.uuid, + '_str': six.text_type(person), + 'first_name': person.first_name, + 'last_name': person.last_name, + 'display_name': person.display_name, + } + + +def includeme(config): + PersonView.defaults(config)