Add new "master" API view class; refactor products and batches to use it

This commit is contained in:
Lance Edgar 2020-03-01 16:45:24 -06:00
parent df00dd600a
commit 113c0af49d
8 changed files with 183 additions and 90 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.
#
@ -81,7 +81,7 @@ class APIMasterView(APIView):
Returns a prefix which (by default) applies to all permissions
leveraged by this view class.
"""
prefix = getattr(cls, 'permission_prefix')
prefix = getattr(cls, 'permission_prefix', None)
if prefix:
return prefix
return cls.get_route_prefix()
@ -371,6 +371,10 @@ class APIMasterView(APIView):
##############################
def autocomplete(self):
"""
View which accepts a single ``term`` param, and returns a list of
autocomplete results to match.
"""
term = self.request.params.get('term', '').strip()
term = self.prepare_autocomplete_term(term)
if not term: