From a64ef0e20e5a8010be15b45d93730f5ed4792370 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 4 Oct 2012 08:40:07 -0700 Subject: [PATCH] add brands autocomplete view --- rattail/pyramid/views/brands.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/rattail/pyramid/views/brands.py b/rattail/pyramid/views/brands.py index 247fe15b..ea7570b8 100644 --- a/rattail/pyramid/views/brands.py +++ b/rattail/pyramid/views/brands.py @@ -26,7 +26,8 @@ ``rattail.pyramid.views.brands`` -- Brand Views """ -from edbob.pyramid.views import SearchableAlchemyGridView, CrudView +from edbob.pyramid.views import ( + SearchableAlchemyGridView, CrudView, AutocompleteView) import rattail @@ -81,6 +82,12 @@ class BrandCrud(CrudView): return fs +class BrandsAutocomplete(AutocompleteView): + + mapped_class = rattail.Brand + fieldname = 'name' + + def includeme(config): config.add_route('brands', '/brands') @@ -88,6 +95,10 @@ def includeme(config): renderer='/brands/index.mako', permission='brands.list') + config.add_route('brands.autocomplete', '/brands/autocomplete') + config.add_view(BrandsAutocomplete, route_name='brands.autocomplete', + renderer='json', permission='brands.list') + config.add_route('brand.create', '/brands/new') config.add_view(BrandCrud, attr='create', route_name='brand.create', renderer='/brands/crud.mako',