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

Merge the controller actions list, metric1D and 2D, in the single action grid.

parent db2325ab
""" Report controllers
July 2014
- use the new technique based on inline script, Ext.grid.Panel, ...
- the controller build a store containing all the information
- the content of the report is defined in the database
"""
import json
import re
......@@ -49,91 +45,46 @@ def graph():
return dict(cfg_store=json.dumps(store), stack_keys=stack_keys, view=config)
def list():
"""List renders by an C{Ext.grid.Panel}.
def grid():
"""Render the report through the C{App.grid.Panel}.
The report can be a list, a metrics 1d or 2d.
The controller extracts the configuration of the list
and builds the configuration for the C{Ext.data.Store}.
The latter is the core component embedded in the
C{App.grid.Panel}.
The list identifier is defined in the viewport
and send using the baseParams techniques.
The controller extracts the configuration of the report form the database.
It builds the DataFrame, extracts the the configuration
for the C{Ext.data.Store} as well as the C{App.grid.Panel}.
The former contains the data displayed in the grid.
The report identifier is defined in the viewport
and send using the baseParams techniques. Possible identifiers
are C{id_lists], C{id_metrics1d} and C{id_metrics2d}.
The identifier is used to instantiate the proper class.
"""
ui_table = virtdb.list_selector
ui_table = virtdb.grid_selector
selector = MySelector(ui_table)
# extract the report configuration and the build the report
if "id_lists" in request.vars:
config = db.lists[request.vars.id_lists]
report = List(config, selector)
# build report and extract the configurations for
# the Ext.data.Store and App.grid.Panel.
config = db.lists[request.vars.id_lists]
report = List(config, selector)
store = report.to_store()
grid = report.to_grid()
# title
title = do_title(config, selector)
elif "id_metrics1d" in request.vars:
config = db.metrics1d[request.vars.id_metrics1d]
report = Metric1D(config, selector)
# delegate the grid rendering to the view
response.view = 'report/grid.html'
return dict(cfg_store=json.dumps(store), grid=grid, title=title)
def metric_1d():
"""One dimension metric renders by an C{App.grid.Panel}.
elif "id_metrics2d" in request.vars:
config = db.metrics2d[request.vars.id_metrics2d]
report = Metric2D(config, selector)
The controller extracts the configuration of the metric
and builds the configuration for the C{Ext.data.Store}
as well as the configuration of the C{Ext.grid.column.Column}.
The metric identifier is defined in the viewport
and send using the baseParams techniques.
else:
return INLINE_ALERT % ("Error", "Report id is not defined.")
"""
ui_table = virtdb.metric_selector_1d
selector = MySelector(ui_table, exclude_fields=('metric',))
# build report and extract the configuration
# for the Ext.data.Store and the App.grid.Panel
config = db.metrics1d[request.vars.id_metrics]
report = Metric1D(config, selector)
# extract the configurations for the Ext.data.Store and App.grid.Panel.
store = report.to_store()
grid = report.to_grid()
# title
# build the report title
title = do_title(config, selector)
# delegate to standard view
response.view = 'report/grid.html'
return dict(cfg_store=json.dumps(store), grid=grid, title=title)
def metric_2d():
"""Two dimensions metric renders by an C{Ext.grid.Panel}.
The controller extracts the configuration of the metric
and builds the configuration for the C{Ext.data.Store}.
The latter is the core component embedded in the
C{App.grid.Panel}.
The metric identifier is defined in the viewport
and send using the baseParams techniques.
"""
ui_table = virtdb.metric_selector_2d
selector = MySelector(ui_table, exclude_fields=('metric',))
# build report and extract the configuration
# for the Ext.data.Store and the App.grid.Panel
config = db.metrics2d[request.vars.id_metrics]
report = Metric2D(config, selector)
store = report.to_store()
grid = report.to_grid()
# title
title = do_title(config, selector)
# delegate the rendering to the standard view
response.view = 'report/grid.html'
# delegate the grid rendering to the view
return dict(cfg_store=json.dumps(store), grid=grid, title=title)
......@@ -309,11 +309,13 @@
'teams': 'équipes',
'Tests': 'Tests',
'The aggregation function applies on the metric field. It is computed on the subset of row having a given values for the group_field x and y.': "La function d'agrégation est appliquée sur les valeurs du champ métrique. Elle est calculée sur le sous-ensemble d'enregisteremnts ayant une certain valeurs pour les champs 'group_field' x et y.",
'The graphs': 'Les graphs',
'The lists': 'les listes',
'the graphs': 'les graphiques',
'The graphs': 'Les graphiques',
'The lists': 'Les listes',
'the lists': 'les listes',
'The metrics': 'Les métriques',
'The metrics 1D': 'Les métriques 1D',
'The metrics 2D': 'Les métriques 2D',
'the metrics 1d': 'les métriques 1d',
'the metrics 2d': 'les métriques 2d',
"The report id '%s' is unknown.": "The report id '%s' is unknown.",
'Time': 'Temps',
'Timestamp': 'Timestamp',
......
# -*- coding: utf-8 -*-
""" metric_selector_1d
""" grid_selector
"""
virtdb.define_table('metric_selector_1d',
virtdb.define_table('grid_selector',
Field('year_start', 'integer', default=year),
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_people_categories', 'reference people_categories', label= T("Quality")),
Field('id_projects', 'reference projects', label=T('Project')))
Field('id_people_categories', 'reference people_categories', label= T("Quality")))
virtdb.metric_selector_1d.category.requires = IS_IN_SET(PEOPLE_CATEGORIES)
virtdb.metric_selector_1d.id_people_categories.requires = IS_IN_DB(db, 'people_categories.code')
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.metric_selector_1d.id_projects.requires = IS_IN_DB(db, 'projects.project')
virtdb.metric_selector_1d.id_teams.requires = IS_IN_DB(db, 'teams.team')
virtdb.grid_selector.id_projects.requires = IS_IN_DB(db, 'projects.project')
virtdb.grid_selector.id_teams.requires = IS_IN_DB(db, 'teams.team')
#-------------------------------------------------------------------------------
#
# FIELDS CONFIGURATiON
#
#-------------------------------------------------------------------------------
fieldsModifier = dbui.FieldsModifier('metric_selector_1d')
fieldsModifier = dbui.FieldsModifier('grid_selector')
fieldsModifier.configure_field('year_start', flex=1)
fieldsModifier.configure_field('year_end', flex=1)
fieldsModifier.merge_fields('year_start', 'year_end', fieldLabel=T('Period'))
......
# -*- coding: utf-8 -*-
""" list_selector
"""
virtdb.define_table('list_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_people', 'reference people', label=T('Person')),
Field('id_projects', 'reference projects', label=T('Project')),
Field('id_fundings', 'reference fundinds', label=T('Agency')),
Field('id_events', 'reference events', label=T('List')))
virtdb.list_selector.category.requires = IS_IN_SET(PEOPLE_CATEGORIES)
virtdb.list_selector.id_people_categories.requires = IS_IN_DB(db, 'people_categories.code')
virtdb.list_selector.id_events.requires = IS_IN_DB(db, 'events.event')
virtdb.list_selector.id_fundings.requires = IS_IN_DB(db, 'fundings.agency')
virtdb.list_selector.id_people.requires = IS_IN_DB(db, 'people.last_name')
virtdb.list_selector.id_projects.requires = IS_IN_DB(db, 'projects.project')
virtdb.list_selector.id_teams.requires = IS_IN_DB(db, 'teams.team')
#-------------------------------------------------------------------------------
#
# FIELDS CONFIGURATiON
#
#-------------------------------------------------------------------------------
fieldsModifier = dbui.FieldsModifier('list_selector')
fieldsModifier.configure_field('year_start', flex=1)
fieldsModifier.configure_field('year_end', flex=1)
fieldsModifier.merge_fields('year_start', 'year_end', fieldLabel=T('Period'))
mytype = 'xcomboboxuserreset'
text = T('select...')
fieldsModifier.configure_field('id_people', 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)
fieldsModifier.configure_field('id_events', emptyText=text, xtype=mytype)
#-------------------------------------------------------------------------------
#
# FORM CONFIGURATiON
#
#-------------------------------------------------------------------------------
# -*- coding: utf-8 -*-
""" metric_selector_2d
"""
virtdb.define_table('metric_selector_2d',
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')))
virtdb.metric_selector_2d.category.requires = IS_IN_SET(PEOPLE_CATEGORIES)
virtdb.metric_selector_2d.id_people_categories.requires = IS_IN_DB(db, 'people_categories.code')
virtdb.metric_selector_2d.id_projects.requires = IS_IN_DB(db, 'projects.project')
virtdb.metric_selector_2d.id_teams.requires = IS_IN_DB(db, 'teams.team')
#-------------------------------------------------------------------------------
#
# FIELDS CONFIGURATiON
#
#-------------------------------------------------------------------------------
fieldsModifier = dbui.FieldsModifier('metric_selector_2d')
fieldsModifier.configure_field('year_start', flex=1)
fieldsModifier.configure_field('year_end', flex=1)
fieldsModifier.merge_fields('year_start', 'year_end', fieldLabel=T('Period'))
mytype = 'xcomboboxuserreset'
text = T('select...')
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)
#-------------------------------------------------------------------------------
#
# FORM CONFIGURATiON
#
#-------------------------------------------------------------------------------
......@@ -68,10 +68,10 @@ helpNode.sort_children()
#
#-------------------------------------------------------------------------------
cfgNode = Node(T('Configure'))
cfgNode.add_child(T('The lists'), to_grid('lists'))
cfgNode.add_child(T('The metrics 1D'), to_grid('metrics1d'))
cfgNode.add_child(T('The metrics 2D'), to_grid('metrics2d'))
cfgNode.add_child(T('The graphs'), to_grid('graphs'))
cfgNode.add_child(T('the lists'), to_grid('lists'))
cfgNode.add_child(T('the metrics 1d'), to_grid('metrics1d'))
cfgNode.add_child(T('the metrics 2d'), to_grid('metrics2d'))
cfgNode.add_child(T('the graphs'), to_grid('graphs'))
#-------------------------------------------------------------------------------
#
......@@ -104,8 +104,8 @@ listNode = Node(T('The lists'))
for row in db(db.lists.id > 0).select(orderby=db.lists.name):
leaf = PanelWithUrlSelector(virtdb.list_selector,
baseUrl=URL('report', 'list'),
leaf = PanelWithUrlSelector(virtdb.grid_selector,
baseUrl=URL('report', 'grid'),
baseParams={'id_lists': row.id})
listNode.add_child(row.name, leaf)
......@@ -119,17 +119,17 @@ metricNode = Node(T('The metrics'))
for row in db(db.metrics1d.id > 0).select(orderby=db.metrics1d.name):
leaf = PanelWithUrlSelector(virtdb.metric_selector_1d,
baseUrl=URL('report', 'metric_1d'),
baseParams={'id_metrics': row.id})
leaf = PanelWithUrlSelector(virtdb.grid_selector,
baseUrl=URL('report', 'grid'),
baseParams={'id_metrics1d': row.id})
metricNode.add_child(row.name, leaf)
for row in db(db.metrics2d.id > 0).select(orderby=db.metrics2d.name):
leaf = PanelWithUrlSelector(virtdb.metric_selector_2d,
baseUrl=URL('report', 'metric_2d'),
baseParams={'id_metrics': row.id})
leaf = PanelWithUrlSelector(virtdb.grid_selector,
baseUrl=URL('report', 'grid'),
baseParams={'id_metrics2d': row.id})
metricNode.add_child(row.name, leaf)
......
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