Commit c359103d authored by Alex Kerney's avatar Alex Kerney

Merge commit '94a10946' into geoa-wkbelement

Conflicts:
	doc/db_geoa.rst
parents caaf7d0e 94a10946
...@@ -37,7 +37,9 @@ Creating simple model ...@@ -37,7 +37,9 @@ Creating simple model
--------------------- ---------------------
GeoAlchemy comes with a `Geometry`_ field that is carefully divorced from the GeoAlchemy comes with a `Geometry`_ field that is carefully divorced from the
`Shapely`_ library. Flask-Admin will use this field so that there are no changes necessary to other code. ``ModelView`` should be imported from ``geoa`` rather than the one imported from ``sqla``:: `Shapely`_ library. Flask-Admin will use this field so that there are no
changes necessary to other code. ``ModelView`` should be imported from
``geoa`` rather than the one imported from ``sqla``::
from geoalchemy2 import Geometry from geoalchemy2 import Geometry
from flask.ext.admin.contrib.geoa import ModelView from flask.ext.admin.contrib.geoa import ModelView
......
...@@ -586,6 +586,14 @@ class ModelView(BaseModelView): ...@@ -586,6 +586,14 @@ class ModelView(BaseModelView):
""" """
return isinstance(filter, filters.BaseSQLAFilter) return isinstance(filter, filters.BaseSQLAFilter)
def handle_filter(self, filter):
column = filter.column
if self._need_join(column.table):
self._filter_joins[column.table.name] = [column.table]
return filter
def scaffold_form(self): def scaffold_form(self):
""" """
Create form from the model. Create form from the model.
......
...@@ -773,6 +773,15 @@ class BaseModelView(BaseView, ActionsMixin): ...@@ -773,6 +773,15 @@ class BaseModelView(BaseView, ActionsMixin):
""" """
return isinstance(filter, filters.BaseFilter) return isinstance(filter, filters.BaseFilter)
def handle_filter(self, filter):
"""
Postprocess (add joins, etc) for a filter.
:param filter:
Filter object to postprocess
"""
return filter
def get_filters(self): def get_filters(self):
""" """
Return a list of filter objects. Return a list of filter objects.
...@@ -785,7 +794,7 @@ class BaseModelView(BaseView, ActionsMixin): ...@@ -785,7 +794,7 @@ class BaseModelView(BaseView, ActionsMixin):
for n in self.column_filters: for n in self.column_filters:
if self.is_valid_filter(n): if self.is_valid_filter(n):
collection.append(n) collection.append(self.handle_filter(n))
else: else:
flt = self.scaffold_filters(n) flt = self.scaffold_filters(n)
if flt: if flt:
...@@ -1109,7 +1118,7 @@ class BaseModelView(BaseView, ActionsMixin): ...@@ -1109,7 +1118,7 @@ class BaseModelView(BaseView, ActionsMixin):
if key in self._filter_args: if key in self._filter_args:
idx, flt = self._filter_args[key] idx, flt = self._filter_args[key]
value = request.args[n] value = request.args[n]
if flt.validate(value): if flt.validate(value):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment