Various grid and form tweaks.

This commit is contained in:
Lance Edgar 2015-02-09 13:20:34 -06:00
parent 3257010a7e
commit eedbc5fb9a
4 changed files with 14 additions and 12 deletions

View file

@ -34,7 +34,8 @@ __all__ = ['AssociationProxyField']
def AssociationProxyField(name, **kwargs): def AssociationProxyField(name, **kwargs):
""" """
Returns a ``Field`` class which is aware of SQLAlchemy association proxies. Returns a FormAlchemy ``Field`` class which is aware of association
proxies.
""" """
class ProxyField(Field): class ProxyField(Field):
@ -45,10 +46,7 @@ def AssociationProxyField(name, **kwargs):
self.renderer.deserialize()) self.renderer.deserialize())
def value(model): def value(model):
try: return getattr(model, name, None)
return getattr(model, name)
except AttributeError:
return None
kwargs.setdefault('value', value) kwargs.setdefault('value', value)
return ProxyField(name, **kwargs) return ProxyField(name, **kwargs)

View file

@ -31,6 +31,7 @@ div.form-wrapper ul.context-menu li {
div.form, div.form,
div.fieldset-form, div.fieldset-form,
div.fieldset { div.fieldset {
clear: left;
float: left; float: left;
margin-top: 10px; margin-top: 10px;
} }

View file

@ -59,7 +59,7 @@ class AlchemyGridView(GridView):
def __call__(self): def __call__(self):
self._data = self.query() self._data = self.query()
grid = self.grid() grid = self.grid()
return grids.util.render_grid(grid) return self.render_grid(grid)
class SortableAlchemyGridView(AlchemyGridView): class SortableAlchemyGridView(AlchemyGridView):
@ -108,7 +108,7 @@ class SortableAlchemyGridView(AlchemyGridView):
self._sort_config = self.sort_config() self._sort_config = self.sort_config()
self._data = self.query() self._data = self.query()
grid = self.grid() grid = self.grid()
return grids.util.render_grid(grid) return self.render_grid(grid)
class PagedAlchemyGridView(SortableAlchemyGridView): class PagedAlchemyGridView(SortableAlchemyGridView):
@ -127,7 +127,7 @@ class PagedAlchemyGridView(SortableAlchemyGridView):
self._data = self.make_pager() self._data = self.make_pager()
grid = self.grid() grid = self.grid()
grid.pager = self._data grid.pager = self._data
return grids.util.render_grid(grid) return self.render_grid(grid)
class SearchableAlchemyGridView(PagedAlchemyGridView): class SearchableAlchemyGridView(PagedAlchemyGridView):
@ -184,5 +184,4 @@ class SearchableAlchemyGridView(PagedAlchemyGridView):
self._data = self.make_pager() self._data = self.make_pager()
grid = self.grid() grid = self.grid()
grid.pager = self._data grid.pager = self._data
kwargs = self.render_kwargs() return self.render_grid(grid, search)
return grids.util.render_grid(grid, search, **kwargs)

View file

@ -62,7 +62,11 @@ class GridView(View):
def render_kwargs(self): def render_kwargs(self):
return {} return {}
def render_grid(self, grid, search=None, **kwargs):
kwargs = self.render_kwargs()
kwargs['search_form'] = search
return grids.util.render_grid(grid, **kwargs)
def __call__(self): def __call__(self):
grid = self.grid() grid = self.grid()
kwargs = self.render_kwargs() return self.render_grid(grid)
return grids.util.render_grid(grid, **kwargs)