Improved query modification logic in alchemy grid views.
This commit is contained in:
parent
8812b74460
commit
d7d7d870ab
|
@ -39,9 +39,12 @@ __all__ = ['AlchemyGridView', 'SortableAlchemyGridView',
|
||||||
|
|
||||||
class AlchemyGridView(GridView):
|
class AlchemyGridView(GridView):
|
||||||
|
|
||||||
def make_query(self):
|
def make_query(self, session=Session):
|
||||||
q = Session.query(self.mapped_class)
|
query = session.query(self.mapped_class)
|
||||||
return q
|
return self.modify_query(query)
|
||||||
|
|
||||||
|
def modify_query(self, query):
|
||||||
|
return query
|
||||||
|
|
||||||
def query(self):
|
def query(self):
|
||||||
return self.make_query()
|
return self.make_query()
|
||||||
|
@ -88,14 +91,9 @@ class SortableAlchemyGridView(AlchemyGridView):
|
||||||
def sort_config(self):
|
def sort_config(self):
|
||||||
return self.make_sort_config(sort=self.sort)
|
return self.make_sort_config(sort=self.sort)
|
||||||
|
|
||||||
def make_query(self):
|
def modify_query(self, query):
|
||||||
query = Session.query(self.mapped_class)
|
return grids.util.sort_query(
|
||||||
query = grids.util.sort_query(
|
|
||||||
query, self._sort_config, self.sort_map(), self.join_map())
|
query, self._sort_config, self.sort_map(), self.join_map())
|
||||||
return query
|
|
||||||
|
|
||||||
def query(self):
|
|
||||||
return self.make_query()
|
|
||||||
|
|
||||||
def make_grid(self, **kwargs):
|
def make_grid(self, **kwargs):
|
||||||
self.update_grid_kwargs(kwargs)
|
self.update_grid_kwargs(kwargs)
|
||||||
|
@ -162,9 +160,8 @@ class SearchableAlchemyGridView(PagedAlchemyGridView):
|
||||||
def search_form(self):
|
def search_form(self):
|
||||||
return self.make_search_form()
|
return self.make_search_form()
|
||||||
|
|
||||||
def make_query(self, session=Session):
|
def modify_query(self, query):
|
||||||
join_map = self.join_map()
|
join_map = self.join_map()
|
||||||
query = session.query(self.mapped_class)
|
|
||||||
query = grids.search.filter_query(
|
query = grids.search.filter_query(
|
||||||
query, self._filter_config, self.filter_map(), join_map)
|
query, self._filter_config, self.filter_map(), join_map)
|
||||||
if hasattr(self, '_sort_config'):
|
if hasattr(self, '_sort_config'):
|
||||||
|
|
Loading…
Reference in a new issue