Commit 9f2603fd authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add in the selector the logic to deal with object category and code.

parent 998b5d02
......@@ -134,9 +134,14 @@ class MySelector(SelectorActiveItems):
and year are systematically excluded.
"""
li = ['id_people_categories', 'id_people_code', 'year_end', 'year_start']
li.extend(exclude_fields)
li = ['id_object_categories',
'id_object_code',
'id_people_categories',
'id_people_code',
'year_end',
'year_start']
li.extend(exclude_fields)
SelectorActiveItems.__init__(self, table, exclude_fields=li)
# add virtual fields
......@@ -324,20 +329,35 @@ class MySelector(SelectorActiveItems):
db = table._db
query = SelectorActiveItems.query(self, table)
# object category and code
id_object_code = self.id_object_code
if id_object_code:
q = db.history.id_object_categories == id_object_code
query = (query) & (q)
id_object_category = self.id_object_categories
if id_object_category:
category = db.object_categories[id_object_category].category
qcat = db.object_categories.category == category
myset = {row.id for row in db(qcat).select(db.object_categories.id)}
q = db.history.id_object_categories.belongs(myset)
query = (query) & (q)
# people category and code
id_people_code = self.id_people_code
if id_people_code:
q = db.history.id_people_categories == id_people_code
query = (query) & (q)
query &= q
id_people_category = self.id_people_categories
if id_people_category:
category = db.people_categories[id_people_category].category
qcat = db.people_categories.category==category
qcat = db.people_categories.category == category
myset = {row.id for row in db(qcat).select(db.people_categories.id)}
q = db.history.id_people_categories.belongs(myset)
query = (query) & (q)
query &= q
return query
......
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