add brands autocomplete view

This commit is contained in:
Lance Edgar 2012-10-04 08:40:07 -07:00
parent 78eb708a9c
commit a64ef0e20e

View file

@ -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',