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

Use alias table to deal with category and quality in selector.

parent 74b2b965
# -*- coding: utf-8 -*-
""" categories
alias tables for people_categories
"""
db.people_categories.with_alias('categories')
......@@ -6,12 +6,15 @@ virtdb.define_table('graph_selector',
Field('year_start', 'integer', default=year),
Field('year_end', 'integer'),
Field('id_teams', 'reference teams', label=T('Team')),
Field('category', 'string'),
Field('id_people_categories', 'reference people_categories', label= T("Quality")),
Field('id_projects', 'reference projects', label=T('Project')))
Field('id_projects', 'reference projects', label=T('Project')),
Field('id_categories', 'reference categories', label= T("Category")),
Field('id_people_categories', 'reference people_categories', label= T("Quality")))
virtdb.graph_selector.category.requires = IS_IN_SET(PEOPLE_CATEGORIES)
virtdb.graph_selector.id_people_categories.requires = IS_IN_DB(db, 'people_categories.code')
virtdb.graph_selector.id_categories.requires = \
IS_IN_DB(db, 'categories.category')
virtdb.graph_selector.id_people_categories.requires = \
IS_IN_DB(db, 'people_categories.code')
virtdb.graph_selector.id_projects.requires = IS_IN_DB(db, 'projects.project')
virtdb.graph_selector.id_teams.requires = IS_IN_DB(db, 'teams.team')
......@@ -29,6 +32,7 @@ fieldsModifier.merge_fields('year_start', 'year_end', fieldLabel=T('Period'))
mytype = 'xcomboboxuserreset'
text = T('select...')
fieldsModifier.configure_field('id_categories', emptyText=text, xtype=mytype)
fieldsModifier.configure_field('id_people_categories', emptyText=text, xtype=mytype)
fieldsModifier.configure_field('id_teams', emptyText=text, xtype=mytype)
fieldsModifier.configure_field('id_projects', emptyText=text, xtype=mytype)
......
......@@ -7,11 +7,14 @@ virtdb.define_table('grid_selector',
Field('year_end', 'integer'),
Field('id_teams', 'reference teams', label=T('Team')),
Field('id_projects', 'reference projects', label=T('Project')),
Field('category', 'string'),
Field('id_categories', 'reference categories', label= T("Category")),
Field('id_people_categories', 'reference people_categories', label= T("Quality")))
virtdb.grid_selector.category.requires = IS_IN_SET(PEOPLE_CATEGORIES)
virtdb.grid_selector.id_people_categories.requires = IS_IN_DB(db, 'people_categories.code')
virtdb.grid_selector.id_categories.requires = \
IS_IN_DB(db, 'categories.category')
virtdb.grid_selector.id_people_categories.requires = \
IS_IN_DB(db, 'people_categories.code')
virtdb.grid_selector.id_projects.requires = IS_IN_DB(db, 'projects.project')
virtdb.grid_selector.id_teams.requires = IS_IN_DB(db, 'teams.team')
......@@ -29,6 +32,7 @@ fieldsModifier.merge_fields('year_start', 'year_end', fieldLabel=T('Period'))
mytype = 'xcomboboxuserreset'
text = T('select...')
fieldsModifier.configure_field('id_categories', emptyText=text, xtype=mytype)
fieldsModifier.configure_field('id_people_categories', emptyText=text, xtype=mytype)
fieldsModifier.configure_field('id_teams', emptyText=text, xtype=mytype)
fieldsModifier.configure_field('id_projects', emptyText=text, xtype=mytype)
......
......@@ -134,7 +134,7 @@ class MySelector(SelectorActiveItems):
and year are systematically excluded.
"""
li = ['category', 'year_end', 'year_start']
li = ['id_categories', 'year_end', 'year_start']
li.extend(exclude_fields)
SelectorActiveItems.__init__(self, table, exclude_fields=li)
......@@ -309,7 +309,7 @@ class MySelector(SelectorActiveItems):
def query(self, table):
"""Supersede the base class method to handle category constraints.
"""Supersede the base class method to handle quality constraints.
@type table: gluon.dal.Table
@param table:
......@@ -325,8 +325,10 @@ class MySelector(SelectorActiveItems):
query = SelectorActiveItems.query(self, table)
# category constraint
if self.category:
q = db.people_categories.category == self.category
id_category = self.id_categories
if id_category:
category = db.people_categories[id_category].category
q = db.people_categories.category == category
query = (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