Refactor autocomplete view logic to leverage new "autocompleters"
finally! this cleans up some view config and AFAIK there is no loss in functionality etc.
This commit is contained in:
parent
e0dff55ffa
commit
a7f4b2e6ef
12 changed files with 65 additions and 375 deletions
4
tailbone/views/vendors/__init__.py
vendored
4
tailbone/views/vendors/__init__.py
vendored
|
@ -26,9 +26,7 @@ Views pertaining to vendors
|
|||
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
from .core import VendorView, VendorsAutocomplete
|
||||
# TODO: deprecate / remove this
|
||||
from .core import VendorsView
|
||||
from .core import VendorView
|
||||
|
||||
|
||||
def includeme(config):
|
||||
|
|
18
tailbone/views/vendors/core.py
vendored
18
tailbone/views/vendors/core.py
vendored
|
@ -32,7 +32,7 @@ from rattail.db import model
|
|||
|
||||
from webhelpers2.html import tags
|
||||
|
||||
from tailbone.views import MasterView, AutocompleteView
|
||||
from tailbone.views import MasterView
|
||||
|
||||
|
||||
class VendorView(MasterView):
|
||||
|
@ -42,6 +42,7 @@ class VendorView(MasterView):
|
|||
model_class = model.Vendor
|
||||
has_versions = True
|
||||
touchable = True
|
||||
supports_autocomplete = True
|
||||
|
||||
labels = {
|
||||
'id': "ID",
|
||||
|
@ -167,21 +168,6 @@ class VendorView(MasterView):
|
|||
(model.VendorContact, 'vendor_uuid'),
|
||||
]
|
||||
|
||||
# TODO: deprecate / remove this
|
||||
VendorsView = VendorView
|
||||
|
||||
|
||||
class VendorsAutocomplete(AutocompleteView):
|
||||
|
||||
mapped_class = model.Vendor
|
||||
fieldname = 'name'
|
||||
|
||||
|
||||
def includeme(config):
|
||||
|
||||
# autocomplete
|
||||
config.add_route('vendors.autocomplete', '/vendors/autocomplete')
|
||||
config.add_view(VendorsAutocomplete, route_name='vendors.autocomplete',
|
||||
renderer='json', permission='vendors.list')
|
||||
|
||||
VendorView.defaults(config)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue