Commit b6416c52 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update selector to replace the data field by query.

parent 51d9b204
......@@ -17,6 +17,19 @@ from plugin_dbui import get_id
DATE_MIN = date(1990, 01, 01)
DATE_MAX = date(2050, 12, 31)
HISTORY_QUERY_FIELDS = [
"id_events",
"id_domains",
"id_fundings",
"id_objects",
"id_object_categories",
"id_people",
"id_people_categories",
"id_projects",
"id_teams",
"year_end",
"year_start"]
def _get_column_names(fields):
"""Snippet to get list of column names from a list of database field.
......@@ -1240,17 +1253,19 @@ def query_history(db, **kwargs):
history = db.history
query = None
for k, v in kwargs.iteritems():
di = {k: kwargs[k] for k in HISTORY_QUERY_FIELDS if k in kwargs}
for k, v in di.iteritems():
if (v in ('', None)) or (k == "data"):
continue
if k == "year_end":
year_end = date(int(kwargs["year_end"]), 12, 31)
year_end = date(int(di["year_end"]), 12, 31)
qi = history.start_date <= year_end
elif k == "year_start":
year_start = date(int(kwargs["year_start"]), 01, 01)
year_start = date(int(di["year_start"]), 01, 01)
qi = (history.end_date == None) | (history.end_date >= year_start)
else:
......@@ -1349,4 +1364,4 @@ def to_extjs_gridcolumns(df):
li.append(cfg)
return li
\ No newline at end of file
return li
......@@ -7,9 +7,6 @@ from gluon.validators import IS_IN_DB
from pydal import Field
TP_DATA = "The field history.data contains the given value."
class Selector(object):
@staticmethod
......@@ -67,7 +64,7 @@ class Selector(object):
"reference object_categories",
label="Code"),
Field("data", "string", comment=TP_DATA, label=""))
Field("query", "text"))
table.id_object_categories.requires = \
IS_IN_DB(db, "alias_object_categories.category")
......
......@@ -16,6 +16,9 @@ FIELD_TYPES = {"gridcolumn": "string",
"datecolumn": "date",
"numbercolumn": "float"}
GROUPING = {"ftype": "grouping",
"groupHeaderTpl": "{name}"}
GROUPING_SUMMARY = {"ftype": "groupingsummary",
"groupHeaderTpl": "{name}",
"startCollapsed": False}
......@@ -130,6 +133,9 @@ class List2(object):
if not df.empty and config.query not in (None, ""):
df.query(config.query, inplace=True)
if not df.empty and selector["query"] not in (None, ""):
df.query(selector["query"], inplace=True)
# ....................................................................
#
# Configure Ext JS store
......@@ -158,17 +164,15 @@ class List2(object):
#
self.grid = Storage(columns=grid_columns, features=[])
if config.summary_group or config.summary_all:
features = []
if len(config.group_field) > 0:
if config.summary_group:
features.append(GROUPING_SUMMARY)
if config.summary_all:
features.append(SUMMARY)
self.grid.features = features
self.grid.features.append(GROUPING_SUMMARY)
else:
self.grid.features.append(GROUPING)
if config.summary_all:
self.grid.features.append(SUMMARY)
def _add_store_fields(self, column):
"""Add ``Ext.data.Field`` to the store configuration
......
......@@ -74,12 +74,7 @@ class SelectorUi(object):
mdf.configure_field("id_teams", emptyText=text, xtype=mytype)
mdf.configure_field("id_projects", emptyText=text, xtype=mytype)
mdf.configure_field(
"data",
header=[T("key"), T("value")],
numColumns=2,
numRows=3,
xtype="xtablefield")
mdf.configure_field("query", hideLabel=True)
#.....................................................................
#
......@@ -117,16 +112,16 @@ class SelectorUi(object):
"collapsed": True,
"items": ["SelectorId_object_categories",
"SelectorId_object_code"]
}, {
"title": T("Event data"),
"collapsed": True,
"layout": "fit",
"items": ["SelectorData"]
}, {
"title": T("Fundings"),
"collapsed": True,
"layout": "fit",
"items": ["SelectorId_fundings"]
}, {
"title": T("Query"),
"collapsed": False,
"layout": "fit",
"items": ["SelectorQuery"]
}
]
......
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