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

Add the class EvtModelSelector and EvtUiSelector.

parent f8c2bb62
# -*- coding: utf-8 -*-
from callbacks import INHIBIT_CASCADE_DELETE
from model_core import EvtModelCore
from model_report import EvtModelReport
\ No newline at end of file
from model_report import EvtModelReport
from model_selector import EvtModelSelector
from ui_core import EvtUiCore
from ui_report import EvtUiReport
from ui_selector import EvtUiSelector
\ No newline at end of file
......@@ -12,7 +12,7 @@ from gluon.validators import IS_IN_DB
class EvtModelCore(object):
"""The core tables for the tev plugin.
"""The core tables.
"""
@staticmethod
......
......@@ -78,7 +78,7 @@ TP_SORTERS = \
class EvtModelReport(object):
"""The report tables for the tev plugin.
"""The report tables.
"""
@staticmethod
......
# -*- coding: utf-8 -*-
"""Definitions of the selector(s)
"""
from gluon.validators import IS_IN_DB
TP_DATA = "The field history.data contains the given value."
class EvtModelSelector(object):
"""The selector tables.
"""
@staticmethod
def create(virtdb, db, T):
"""Create all the tables for selector.
Args:
virtdb (pyDAL.DAL): connection to the virtual database
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
"""
EvtModelSelector.selector(virtdb, db, T)
@staticmethod
def selector(virtdb, db, T):
"""selector table.
Note:
selector table are store in a virtual database.
Args:
virtdb (pyDAL.DAL): connection to the virtual database
db (pyDAL.DAL): connection to the database of the application
T (gluon.languages.translator): language translator
Returns:
pyDAL.Table
"""
table = virtdb.define_table(
"selector",
Field("year_start", "integer", default=year, label="Start"),
Field("year_end", "integer", label="End"),
Field("id_domains", "reference domains", label="Domain"),
Field("id_teams", "reference teams", label="Team"),
Field("id_projects", "reference projects", label="Project"),
Field("id_fundings", "reference fundings", label=""),
Field("id_people_categories",
"reference alias_people_categories",
label="Category"),
Field("id_people_code",
"reference people_categories",
label="Quality"),
Field("id_object_categories",
"reference alias_object_categories",
label="Category"),
Field("id_object_code",
"reference object_categories",
label="Code"),
Field("data", "string", comment=TP_DATA, label=""))
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_categories.requires = \
IS_IN_DB(db, "alias_people_categories.category")
table.id_people_code.requires = IS_IN_DB(db, "people_categories.code")
table.id_domains.requires = IS_IN_DB(db, "domains.domain")
table.id_fundings.requires = IS_IN_DB(db, "fundings.agency")
table.id_projects.requires = IS_IN_DB(db, "projects.project")
table.id_teams.requires = IS_IN_DB(db, "teams.team")
......@@ -7,12 +7,12 @@ import plugin_dbui as dbui
fieldsModifier = dbui.FieldsModifier
formModifier = dbui.FormModifier
mdf = dbui.GridModifier
gridModifier = dbui.GridModifier
storeModifier = dbui.StoreModifier
class EvtUiCore(object):
"""The User interface for the core tables of the tev plugin.
"""The User interface for the core tables.
"""
@staticmethod
......
......@@ -5,14 +5,14 @@
import plugin_dbui as dbui
mdf = dbui.FieldsModifier
mdf = dbui.FormModifier
mdf = dbui.GridModifier
fieldsModifier = dbui.FieldsModifier
formModifier = dbui.FormModifier
gridModifier = dbui.GridModifier
storeModifier = dbui.StoreModifier
class EvtUiReport(object):
"""The User interface for the report tables of the tev plugin.
"""The User interface for the report tables.
"""
@staticmethod
......
# -*- coding: utf-8 -*-
"""User Interface for selectors
"""
from gluon.html import URL
from gluon.storage import Storage
import plugin_dbui as dbui
fieldsModifier = dbui.FieldsModifier
formModifier = dbui.FormModifier
gridModifier = dbui.GridModifier
storeModifier = dbui.StoreModifier
class EvtUiSelector(object):
"""The User interface for the report tables.
"""
@staticmethod
def selector(virtdb, db, T):
"""UI for the selector table
Args:
virtdb (pyDAL.DAL): connection to the virtual database
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
Returns:
gluon.storage.Storage:
the configuration of the PanelWithUrlSelector.
"""
#.....................................................................
#
# Fields
#
mdf = fieldsModifier("selector")
mytype = "xcomboboxuserreset"
text = T("select...")
mdf.configure_field("id_categories", emptyText=text, xtype=mytype)
mdf.configure_field("id_domains", emptyText=text, xtype=mytype)
mdf.configure_field("id_fundings", emptyText=text, xtype=mytype)
mdf.configure_field("id_object_categories",
emptyText=text,
xtype=mytype)
mdf.configure_field("id_object_code", emptyText=text, xtype=mytype)
mdf.configure_field("id_people_categories",
emptyText=text,
xtype=mytype)
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)
mdf.configure_field(
"data",
header=[T("key"), T("value")],
numColumns=2,
numRows=3,
xtype="xtablefield")
#.....................................................................
#
# PanelWithUrlSelector
# - configure it once since it is u0sed many times (lists, ...)
# - organise fields within an accordion layout
#
# map between field name and field configuration
# keys are the field name or field label for merge fields
mapfields = Storage()
for cfgfield in dbui.to_fields(virtdb.selector):
key = (cfgfield.name if cfgfield.name else cfgfield.fieldLabel)
mapfields[key] = cfgfield
# Organise fields within different panels
# and replace field name by their configuration
items = [
{
"title": T("Period"),
"items": ["SelectorYear_start",
"SelectorYear_end"]
}, {
"title": T("Metadata"),
"items": ["SelectorId_domains",
"SelectorId_teams",
"SelectorId_projects"]
}, {
"title": T("People"),
"collapsed": True,
"items": ["SelectorId_people_categories",
"SelectorId_people_code"]
}, {
"title": T("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"]
}
]
for panel in items:
panelitems = panel["items"]
for i in xrange(len(panelitems)):
panelitems[i] = mapfields[panelitems[i]]
# configure the accordion layout
# several panel can be open at the same time (multi)
layout = dict(
multi=True,
titleCollapse=True,
type="accordion")
# wrap fields within a FieldSet
fieldset = dbui.FieldSet(
defaults=dict(frame=True),
items=items,
layout=layout,
plugins=["pFormToolTip"],
title=T("Select"))
# configure the PanelWithUrlSelector
selector_panel = dbui.PanelWithUrlSelector(
baseUrl=URL("report", "grid"),
selectorItems=fieldset)
return selector_panel
@staticmethod
def tune(virtdb, db, T):
"""Tune the configuration of the UI for selectors.
Args:
virtdb (pyDAL.DAL): connection to the virtual database
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
"""
EvtUiSelector.selector(virtdb, db, T)
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