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

Fix issues related to date and categories selections.

parent 86049fd6
......@@ -23,9 +23,11 @@ HISTORY_QUERY_FIELDS = [
"id_objects",
"id_object_categories",
"id_people",
"id_people_categories",
"id_people_code",
"id_projects",
"id_teams",
"object_categories_category",
"people_categories_category",
"year_end",
"year_start"]
......@@ -1240,11 +1242,13 @@ def query_history(db, **kwargs):
id_domains (int):
id_fundings (int):
id_objects (int):
id_object_categories (int):
id_object_code (int): select object per category.code
id_people (int):
id_people_categories (int):
id_people_code (int): select people per category.code (quality)
id_projects (int):
id_teams (int):
object_categories_category (str): select object per category
people_categories_category (str): select people per category
year_end (date):
year_start (date):
......@@ -1268,7 +1272,23 @@ def query_history(db, **kwargs):
elif k == "year_start":
year_start = date(int(di["year_start"]), 01, 01)
qi = (history.end_date is None) | (history.end_date >= year_start)
qi = (history.end_date == None) | (history.end_date >= year_start)
elif k == "id_object_code":
qi = history.id_object_categories == int(v)
elif k == "object_categories_category":
object_cats = db.object_categories
cat_ids = db(object_cats.category == v)._select(object_cats.id)
qi = history.id_object_categories.belongs(cat_ids)
elif k == "id_people_code":
qi = history.id_people_categories == int(v)
elif k == "people_categories_category":
people_cats = db.people_categories
cat_ids = db(people_cats.category == v)._select(people_cats.id)
qi = history.id_people_categories.belongs(cat_ids)
else:
qi = history[k] == v
......
......@@ -51,9 +51,7 @@ class Selector(object):
Field("id_people", "reference people", label="Last name"),
Field("id_people_categories",
"reference alias_people_categories",
label="Category"),
Field("people_categories_category", "string", label="Category"),
Field("id_people_code",
"reference people_categories",
......@@ -61,9 +59,7 @@ class Selector(object):
Field("id_objects", "reference objects", label="Reference"),
Field("id_object_categories",
"reference alias_object_categories",
label="Category"),
Field("object_categories_category", "string", label="Category"),
Field("id_object_code",
"reference object_categories",
......@@ -80,21 +76,11 @@ class Selector(object):
Field("is_graph", "boolean"),
Field("graph", "json", default=DEF_GRAPH))
table.id_object_categories.requires = \
IS_IN_DB(db, "alias_object_categories.category")
table.id_object_code.requires = \
IS_IN_DB(db, "object_categories.code")
table.id_people.requires = \
IS_IN_DB(db, "people.last_name")
table.id_people_categories.requires = \
IS_IN_DB(db, "alias_people_categories.category")
table.id_domains.requires = IS_IN_DB(db, "domains.domain")
table.id_fundings.requires = IS_IN_DB(db, "fundings.agency")
table.id_objects.requires = IS_IN_DB(db, "objects.reference")
table.id_object_code.requires = IS_IN_DB(db, "object_categories.code")
table.id_people.requires = IS_IN_DB(db, "people.last_name")
table.id_people_code.requires = IS_IN_DB(db, "people_categories.code")
table.id_projects.requires = IS_IN_DB(db, "projects.project")
table.id_teams.requires = IS_IN_DB(db, "teams.team")
......
......@@ -55,23 +55,31 @@ class SelectorUi(object):
mdf.configure_field("id_fundings", emptyText=text, xtype=mytype)
mdf.configure_field("id_objects", emptyText=text, xtype=mytype)
# to have an unique key use xcomboboxmaster instead of userreset
mdf.configure_field("id_object_categories",
emptyText=text,
refStore="alias_object_categoriesStore",
userReset=True,
xtype="xcomboboxmaster")
# combobox for object categories
li = [el.category for el in db(db.object_categories.id > 0).select()]
categories = sorted(set(li))
mdf.configure_field("object_categories_category",
allowBlank=True,
emptyText=T("select..."),
store=categories,
xtype="combobox")
# to have an unique key use xcomboboxmaster instead of userreset
mdf.configure_field("id_object_code", emptyText=text, xtype=mytype)
mdf.configure_field("id_people", emptyText=text, xtype=mytype)
# to have an unique key use xcomboboxmaster instead of userreset
mdf.configure_field("id_people_categories",
emptyText=text,
refStore="alias_people_categoriesStore",
userReset=True,
xtype="xcomboboxmaster")
# combobox for people categories
li = [el.category for el in db(db.people_categories.id > 0).select()]
categories = sorted(set(li))
mdf.configure_field("people_categories_category",
allowBlank=True,
emptyText=T("select..."),
store=categories,
xtype="combobox")
# to have an unique key use xcomboboxmaster instead of userreset
mdf.configure_field("id_people_code", emptyText=text, xtype=mytype)
mdf.configure_field("id_teams", emptyText=text, xtype=mytype)
mdf.configure_field("id_projects", emptyText=text, xtype=mytype)
......@@ -124,7 +132,7 @@ class SelectorUi(object):
"collapsible": True,
"collapsed": True,
"items": [mapfields["SelectorId_people"],
mapfields["SelectorId_people_categories"],
mapfields["SelectorPeople_categories_category"],
mapfields["SelectorId_people_code"]],
"xtype": "fieldset"
}, {
......
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