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

View file

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