add LabelProfile.visible field support

This commit is contained in:
Lance Edgar 2012-11-06 18:24:12 -08:00
parent 5f7fd2401e
commit 78f0dad6d0
2 changed files with 10 additions and 2 deletions

View file

@ -33,6 +33,7 @@ import formalchemy
from webhelpers.html import HTML from webhelpers.html import HTML
from edbob.pyramid import Session from edbob.pyramid import Session
from edbob.pyramid.grids.search import BooleanSearchFilter
from edbob.pyramid.views import SearchableAlchemyGridView, CrudView from edbob.pyramid.views import SearchableAlchemyGridView, CrudView
import rattail import rattail
@ -46,11 +47,15 @@ class ProfilesGrid(SearchableAlchemyGridView):
def filter_map(self): def filter_map(self):
return self.make_filter_map( return self.make_filter_map(
exact=['code'], exact=['code', 'visible'],
ilike=['description']) ilike=['description'])
def filter_config(self):
return self.make_filter_config(
filter_factory_visible=BooleanSearchFilter)
def sort_map(self): def sort_map(self):
return self.make_sort_map('ordinal', 'code', 'description') return self.make_sort_map('ordinal', 'code', 'description', 'visible')
def grid(self): def grid(self):
g = self.make_grid() g = self.make_grid()
@ -59,6 +64,7 @@ class ProfilesGrid(SearchableAlchemyGridView):
g.ordinal, g.ordinal,
g.code, g.code,
g.description, g.description,
g.visible,
], ],
readonly=True) readonly=True)
if self.request.has_perm('label_profiles.read'): if self.request.has_perm('label_profiles.read'):
@ -104,6 +110,7 @@ class ProfileCrud(CrudView):
fs.printer_spec, fs.printer_spec,
fs.formatter_spec, fs.formatter_spec,
fs.format, fs.format,
fs.visible,
]) ])
return fs return fs

View file

@ -181,6 +181,7 @@ class ProductsGrid(SearchableAlchemyGridView):
def render_kwargs(self): def render_kwargs(self):
q = Session.query(rattail.LabelProfile) q = Session.query(rattail.LabelProfile)
q = q.filter(rattail.LabelProfile.visible == True)
q = q.order_by(rattail.LabelProfile.ordinal) q = q.order_by(rattail.LabelProfile.ordinal)
return {'label_profiles': q.all()} return {'label_profiles': q.all()}