Commit 94a10946 authored by Alex Kerney's avatar Alex Kerney

Merge pull request #1 from mrjoes/master

Up to date
parents f5748f25 58789da1
...@@ -45,6 +45,7 @@ use this field rather that the one that ships with GeoAlchemy when defining your ...@@ -45,6 +45,7 @@ use this field rather that the one that ships with GeoAlchemy when defining your
models:: models::
from flask.ext.admin.contrib.geoa.sqltypes import Geometry from flask.ext.admin.contrib.geoa.sqltypes import Geometry
from flask.ext.admin.contrib.geoa import ModelView
# .. flask initialization # .. flask initialization
db = SQLAlchemy(app) db = SQLAlchemy(app)
...@@ -61,6 +62,9 @@ models:: ...@@ -61,6 +62,9 @@ models::
db.create_all() db.create_all()
app.run('0.0.0.0', 8000) app.run('0.0.0.0', 8000)
Note that you also have to use the ``ModelView`` class imported from ``geoa``,
rather than the one imported from ``sqla``.
Limitations Limitations
----------- -----------
......
...@@ -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