diff --git a/tailbone/forms/fields.py b/tailbone/forms/fields.py index 80fe001f..a5ad17f5 100644 --- a/tailbone/forms/fields.py +++ b/tailbone/forms/fields.py @@ -34,7 +34,8 @@ __all__ = ['AssociationProxyField'] 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): @@ -45,10 +46,7 @@ def AssociationProxyField(name, **kwargs): self.renderer.deserialize()) def value(model): - try: - return getattr(model, name) - except AttributeError: - return None + return getattr(model, name, None) kwargs.setdefault('value', value) return ProxyField(name, **kwargs) diff --git a/tailbone/static/css/forms.css b/tailbone/static/css/forms.css index 760232b1..5b26f63a 100644 --- a/tailbone/static/css/forms.css +++ b/tailbone/static/css/forms.css @@ -31,6 +31,7 @@ div.form-wrapper ul.context-menu li { div.form, div.fieldset-form, div.fieldset { + clear: left; float: left; margin-top: 10px; } diff --git a/tailbone/views/grids/alchemy.py b/tailbone/views/grids/alchemy.py index 922683a5..ffb4ed48 100644 --- a/tailbone/views/grids/alchemy.py +++ b/tailbone/views/grids/alchemy.py @@ -59,7 +59,7 @@ class AlchemyGridView(GridView): def __call__(self): self._data = self.query() grid = self.grid() - return grids.util.render_grid(grid) + return self.render_grid(grid) class SortableAlchemyGridView(AlchemyGridView): @@ -108,7 +108,7 @@ class SortableAlchemyGridView(AlchemyGridView): self._sort_config = self.sort_config() self._data = self.query() grid = self.grid() - return grids.util.render_grid(grid) + return self.render_grid(grid) class PagedAlchemyGridView(SortableAlchemyGridView): @@ -127,7 +127,7 @@ class PagedAlchemyGridView(SortableAlchemyGridView): self._data = self.make_pager() grid = self.grid() grid.pager = self._data - return grids.util.render_grid(grid) + return self.render_grid(grid) class SearchableAlchemyGridView(PagedAlchemyGridView): @@ -184,5 +184,4 @@ class SearchableAlchemyGridView(PagedAlchemyGridView): self._data = self.make_pager() grid = self.grid() grid.pager = self._data - kwargs = self.render_kwargs() - return grids.util.render_grid(grid, search, **kwargs) + return self.render_grid(grid, search) diff --git a/tailbone/views/grids/core.py b/tailbone/views/grids/core.py index 157c2817..a2cfd48d 100644 --- a/tailbone/views/grids/core.py +++ b/tailbone/views/grids/core.py @@ -62,7 +62,11 @@ class GridView(View): def render_kwargs(self): 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): grid = self.grid() - kwargs = self.render_kwargs() - return grids.util.render_grid(grid, **kwargs) + return self.render_grid(grid)