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

Revisit import from plugin_dbui in model classes.

parent d6c9e8ed
......@@ -2,12 +2,14 @@
"""Definitions of the core tables
"""
import plugin_dbui as dbui
from callbacks import INHIBIT_CASCADE_DELETE
from datetime import datetime
from gluon.validators import IS_IN_DB
from plugin_dbui import (INHIBIT_DELETE_UNDEF,
INHIBIT_UPDATE_UNDEF,
UNDEF_ID)
from pydal import Field
......@@ -27,8 +29,8 @@ class Core(object):
"""
table._before_delete.append(INHIBIT_CASCADE_DELETE)
table._before_delete.append(dbui.INHIBIT_DELETE_UNDEF)
table._before_update.append(dbui.INHIBIT_UPDATE_UNDEF)
table._before_delete.append(INHIBIT_DELETE_UNDEF)
table._before_update.append(INHIBIT_UPDATE_UNDEF)
@staticmethod
def define_tables(db, T):
......@@ -134,7 +136,7 @@ class Core(object):
pyDAL.Table
"""
undef_id = dbui.UNDEF_ID
undef_id = UNDEF_ID
today = datetime.now().strftime("%Y-%m-%d")
table = db.define_table(
......
......@@ -2,14 +2,13 @@
"""User Interface for the core tables
"""
import plugin_dbui as dbui
from gluon import current
fieldsModifier = dbui.FieldsModifier
formModifier = dbui.FormModifier
gridModifier = dbui.GridModifier
storeModifier = dbui.StoreModifier
from plugin_dbui import (FieldsModifier,
FormModifier,
GridModifier,
map_tabpanel,
StoreModifier,
UNDEF)
class CoreUi(object):
......@@ -48,7 +47,7 @@ class CoreUi(object):
#
# Store
#
storeModifier("domains").orderby(db.domains.domain)
StoreModifier("domains").orderby(db.domains.domain)
@staticmethod
def events(db, T):
......@@ -63,7 +62,7 @@ class CoreUi(object):
#
# Fields
#
mdf = fieldsModifier("events")
mdf = FieldsModifier("events")
mdf.configure_field("data",
colProperty={"width": 70},
colType={"width": 70},
......@@ -74,19 +73,19 @@ class CoreUi(object):
#
# Form
#
mdf = formModifier("events")
mdf = FormModifier("events")
mdf.merge_fields("event", "definition", title=T("General"))
mdf.merge_fields("data", title=T("Data model"))
mdf.set_mapper(dbui.map_tabpanel)
mdf.set_mapper(map_tabpanel)
mdf.configure(plugins=["pUserDataConsistency"], width=450)
# ....................................................................
#
# Grid
#
mdf = gridModifier("events")
mdf = GridModifier("events")
mdf.configure_column("event", width=30)
mdf.hide_columns("data")
......@@ -109,7 +108,7 @@ class CoreUi(object):
#
# Store
#
storeModifier("events").orderby(db.events.event)
StoreModifier("events").orderby(db.events.event)
@staticmethod
def fundings(db, T):
......@@ -124,14 +123,14 @@ class CoreUi(object):
#
# Grid
#
mdf = gridModifier("fundings")
mdf = GridModifier("fundings")
mdf.configure_column("agency", width=40)
# ....................................................................
#
# Store
#
storeModifier("fundings").orderby(db.fundings.agency)
StoreModifier("fundings").orderby(db.fundings.agency)
@staticmethod
def history(db, T):
......@@ -142,13 +141,13 @@ class CoreUi(object):
T (gluon.languages.translator): language translator
"""
undef = current.T(dbui.UNDEF)
undef = current.T(UNDEF)
# ....................................................................
#
# Fields
#
mdf = fieldsModifier("history")
mdf = FieldsModifier("history")
mdf.configure_field("data",
dictFieldData="EventsData",
......@@ -169,7 +168,7 @@ class CoreUi(object):
#
# Form
#
mdf = formModifier("history")
mdf = FormModifier("history")
mdf.merge_fields("id_domains",
"id_teams",
"id_projects",
......@@ -192,7 +191,7 @@ class CoreUi(object):
mdf.merge_fields("note", title=T("Note"))
mdf.set_mapper(dbui.map_tabpanel)
mdf.set_mapper(map_tabpanel)
mdf.configure(buttonAlign="right", width=450)
......@@ -200,7 +199,7 @@ class CoreUi(object):
#
# Grid
#
mdf = gridModifier("history")
mdf = GridModifier("history")
row_widget = {
"expandOnDblClick": False,
......@@ -261,7 +260,7 @@ class CoreUi(object):
#
# Store
#
storeModifier("history").orderby(~db.history.id)
StoreModifier("history").orderby(~db.history.id)
@staticmethod
def object_categories(db, T):
......@@ -276,7 +275,7 @@ class CoreUi(object):
#
# Grid
#
mdf = gridModifier("object_categories")
mdf = GridModifier("object_categories")
mdf.configure_column("code", width=20)
mdf.configure_column("category", width=20)
......@@ -284,7 +283,7 @@ class CoreUi(object):
#
# Store
#
storeModifier("object_categories").orderby(db.object_categories.code)
StoreModifier("object_categories").orderby(db.object_categories.code)
@staticmethod
def objects(db, T):
......@@ -299,7 +298,7 @@ class CoreUi(object):
#
# Grid
#
mdf = gridModifier("objects")
mdf = GridModifier("objects")
mdf.append_filter(("reference", "contains", T("contains")))
mdf.append_filter(("serial_number", "contains", T("contains")))
......@@ -311,7 +310,7 @@ class CoreUi(object):
#
# Store
#
storeModifier("objects").orderby(db.objects.reference)
StoreModifier("objects").orderby(db.objects.reference)
@staticmethod
def people_categories(db, T):
......@@ -326,7 +325,7 @@ class CoreUi(object):
#
# Grid
#
mdf = gridModifier("people_categories")
mdf = GridModifier("people_categories")
mdf.configure_column("code", width=20)
mdf.configure_column("category", width=20)
......@@ -334,7 +333,7 @@ class CoreUi(object):
#
# Store
#
storeModifier("people_categories").orderby(db.people_categories.code)
StoreModifier("people_categories").orderby(db.people_categories.code)
@staticmethod
def people(db, T):
......@@ -349,7 +348,7 @@ class CoreUi(object):
#
# Grid
#
mdf = gridModifier("people")
mdf = GridModifier("people")
mdf.configure_column("birth_date", width=20)
mdf.configure_column("first_name", width=30)
mdf.configure_column("initials", width=15)
......@@ -365,7 +364,7 @@ class CoreUi(object):
#
# Store
#
storeModifier("people").orderby(db.people.last_name)
StoreModifier("people").orderby(db.people.last_name)
@staticmethod
def projects(db, T):
......@@ -380,14 +379,14 @@ class CoreUi(object):
#
# Grid
#
mdf = gridModifier("projects")
mdf = GridModifier("projects")
mdf.configure_column("project", width=20)
# ....................................................................
#
# Store
#
storeModifier("projects").orderby(db.projects.project)
StoreModifier("projects").orderby(db.projects.project)
@staticmethod
def teams(db, T):
......@@ -402,11 +401,11 @@ class CoreUi(object):
#
# Grid
#
mdf = gridModifier("teams")
mdf = GridModifier("teams")
mdf.configure_column("team", width=20)
# ....................................................................
#
# Store
#
storeModifier("teams").orderby(db.teams.team)
StoreModifier("teams").orderby(db.teams.team)
......@@ -2,13 +2,11 @@
"""User Interface for the report tables
"""
import plugin_dbui as dbui
fieldsModifier = dbui.FieldsModifier
formModifier = dbui.FormModifier
gridModifier = dbui.GridModifier
storeModifier = dbui.StoreModifier
from plugin_dbui import (FieldsModifier,
FormModifier,
GridModifier,
map_tabpanel,
StoreModifier)
COLUMN_GUIDE = "All columns will be configured when the field is empty"
......@@ -56,7 +54,7 @@ class ReportUi(object):
#
# Fields
#
mdf = fieldsModifier("lists2")
mdf = FieldsModifier("lists2")
mdf.configure_field("columns",
editorHeight=240,
......@@ -101,7 +99,7 @@ class ReportUi(object):
#
# Form
#
mdf = formModifier("lists2")
mdf = FormModifier("lists2")
mdf.merge_fields("name",
"title",
......@@ -125,14 +123,14 @@ class ReportUi(object):
"summary_all",
title=T("Summary"))
mdf.set_mapper(dbui.map_tabpanel)
mdf.set_mapper(map_tabpanel)
mdf.configure(width=450)
# ....................................................................
#
# Grid
#
mdf = gridModifier("lists2")
mdf = GridModifier("lists2")
mdf.configure_column("name", width=30)
mdf.hide_columns("columns",
"conditions",
......@@ -151,7 +149,7 @@ class ReportUi(object):
#
# Store
#
storeModifier("lists2").orderby(db.lists2.name)
StoreModifier("lists2").orderby(db.lists2.name)
@staticmethod
def metrics2d2(db, T):
......@@ -166,7 +164,7 @@ class ReportUi(object):
#
# Fields
#
mdf = fieldsModifier("metrics2d2")
mdf = FieldsModifier("metrics2d2")
mdf.configure_field("definition", height=110)
......@@ -202,7 +200,7 @@ class ReportUi(object):
#
# Form
#
mdf = formModifier("metrics2d2")
mdf = FormModifier("metrics2d2")
mdf.merge_fields("name",
"title",
......@@ -228,14 +226,14 @@ class ReportUi(object):
mdf.merge_fields("graph",
title=T("Graph"))
mdf.set_mapper(dbui.map_tabpanel)
mdf.set_mapper(map_tabpanel)
mdf.configure(width=450)
# ....................................................................
#
# Grid
#
mdf = gridModifier("metrics2d2")
mdf = GridModifier("metrics2d2")
mdf.configure_column("name", width=30)
mdf.hide_columns("aggregate_func_z",
"eval",
......@@ -254,4 +252,4 @@ class ReportUi(object):
#
# Store
#
storeModifier("metrics2d2").orderby(db.metrics2d2.name)
StoreModifier("metrics2d2").orderby(db.metrics2d2.name)
......@@ -4,13 +4,11 @@
"""
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
from plugin_dbui import (FieldsModifier,
FieldSet,
map_tabpanel,
PanelWithUrlSelector,
to_fields)
class SelectorUi(object):
......@@ -47,7 +45,7 @@ class SelectorUi(object):
#
# Fields
#
mdf = fieldsModifier("selector_list")
mdf = FieldsModifier("selector_list")
mytype = "xcomboboxuserreset"
text = T("select...")
......@@ -105,7 +103,7 @@ class SelectorUi(object):
# 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_list):
for cfgfield in to_fields(virtdb.selector_list):
key = (cfgfield.name if cfgfield.name else cfgfield.fieldLabel)
mapfields[key] = cfgfield
......@@ -157,7 +155,7 @@ class SelectorUi(object):
]
# wrap fields within a FieldSet
fieldset1 = dbui.FieldSet(
fieldset1 = FieldSet(
defaults=dict(frame=True, layout="form"),
items=items,
layout="anchor",
......@@ -165,9 +163,9 @@ class SelectorUi(object):
title=T("Select"))
# configure the PanelWithUrlSelector
selector_panel = dbui.PanelWithUrlSelector(
selector_panel = PanelWithUrlSelector(
baseUrl=URL("report", "grid"),
selectorItems=dbui.map_tabpanel([fieldset1]))
selectorItems=map_tabpanel([fieldset1]))
return selector_panel
......@@ -189,7 +187,7 @@ class SelectorUi(object):
#
# Fields
#
mdf = fieldsModifier("selector_metric2d")
mdf = FieldsModifier("selector_metric2d")
mytype = "xcomboboxuserreset"
text = T("select...")
......@@ -251,7 +249,7 @@ class SelectorUi(object):
# 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_metric2d):
for cfgfield in to_fields(virtdb.selector_metric2d):
key = (cfgfield.name if cfgfield.name else cfgfield.fieldLabel)
mapfields[key] = cfgfield
......@@ -303,7 +301,7 @@ class SelectorUi(object):
]
# wrap fields within a FieldSet
fieldset1 = dbui.FieldSet(
fieldset1 = FieldSet(
defaults=dict(frame=True, layout="form"),
items=items,
layout="anchor",
......@@ -333,7 +331,7 @@ class SelectorUi(object):
}
]
fieldset2 = dbui.FieldSet(
fieldset2 = FieldSet(
defaults=dict(frame=True),
items=items,
layout="anchor",
......@@ -354,7 +352,7 @@ class SelectorUi(object):
}
]
fieldset3 = dbui.FieldSet(
fieldset3 = FieldSet(
defaults=dict(frame=True),
items=items,
layout="anchor",
......@@ -362,9 +360,9 @@ class SelectorUi(object):
title=T("Graph"))
# configure the PanelWithUrlSelector
selector_panel = dbui.PanelWithUrlSelector(
selector_panel = PanelWithUrlSelector(
baseUrl=URL("report", "grid"),
selectorItems=dbui.map_tabpanel([fieldset1, fieldset2, fieldset3]))
selectorItems=map_tabpanel([fieldset1, fieldset2, fieldset3]))
return selector_panel
......@@ -386,7 +384,7 @@ class SelectorUi(object):
#
# Fields
#
mdf = fieldsModifier("selector_source")
mdf = FieldsModifier("selector_source")
mytype = "xcomboboxuserreset"
text = T("select...")
......@@ -445,7 +443,7 @@ class SelectorUi(object):
# 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_source):
for cfgfield in to_fields(virtdb.selector_source):
key = (cfgfield.name if cfgfield.name else cfgfield.fieldLabel)
mapfields[key] = cfgfield
......@@ -498,7 +496,7 @@ class SelectorUi(object):
]
# wrap fields within a FieldSet
fieldset1 = dbui.FieldSet(
fieldset1 = FieldSet(
defaults=dict(frame=True, layout="form"),
items=items,
layout="anchor",
......@@ -506,8 +504,8 @@ class SelectorUi(object):
title=T("Select"))
# configure the PanelWithUrlSelector
selector_panel = dbui.PanelWithUrlSelector(
selector_panel = PanelWithUrlSelector(
baseUrl=URL("report", "grid"),
selectorItems=dbui.map_tabpanel([fieldset1]))
selectorItems=map_tabpanel([fieldset1]))
return selector_panel
......@@ -8,11 +8,12 @@ import plugin_dbui as dbui
from event import Event
from gluon import current
from gluon.html import URL
from ui_selector import SelectorUi
Node = dbui.Node
Panel = dbui.Panel
to_grid = dbui.to_gridPanel
from plugin_dbui import (Node,
Panel,
to_gridPanel)
from ui_selector import SelectorUi
class ViewportUi(object):
......@@ -73,9 +74,12 @@ class ViewportUi(object):
add_child = node.add_child
add_child(T("users"), to_grid(db.auth_user))
add_child(T("groups"), to_grid(db.auth_group))
add_child(T("relation user / groups"), to_grid(db.auth_membership))
add_child(T("users"), to_gridPanel(db.auth_user))
add_child(T("groups"), to_gridPanel(db.auth_group))
add_child(
T("relation user / groups"),
to_gridPanel(db.auth_membership))
return node
......@@ -139,8 +143,8 @@ class ViewportUi(object):
node = Node(T("Configure lists and metrics"))
add_child = node.add_child
add_child(T("the lists"), to_grid(db.lists2))
add_child(T("the metrics 2d"), to_grid(db.metrics2d2))
add_child(T("the lists"), to_gridPanel(db.lists2))
add_child(T("the metrics 2d"), to_gridPanel(db.metrics2d2))
return node
......@@ -159,8 +163,8 @@ class ViewportUi(object):
node = Node(T("Events"))
add_child = node.add_child
add_child(T("definitions"), to_grid(db.events))
add_child(T("history"), to_grid(db.history))
add_child(T("definitions"), to_gridPanel(db.events))
add_child(T("history"), to_gridPanel(db.history))
return node
......@@ -182,10 +186,10 @@ class ViewportUi(object):
# Immediate translation is required by node.short_children
add_child = node.add_child
add_child(T("domains", lazy=False), to_grid(db.domains))
add_child(T("fundings", lazy=False), to_grid(db.fundings))
add_child(T("teams", lazy=False), to_grid(db.teams))
add_child(T("projects", lazy=False), to_grid(db.projects))
add_child(T("domains", lazy=False), to_gridPanel(db.domains))
add_child(T("fundings", lazy=False), to_gridPanel(db.fundings))
add_child(T("teams", lazy=False), to_gridPanel(db.teams))
add_child(T("projects", lazy=False), to_gridPanel(db.projects))
node.sort_children()
......@@ -265,15 +269,17 @@ class ViewportUi(object):
# Immediate translation is required by node.short_children
add_child = node.add_child
add_child(T("people", lazy=False), to_grid(db.people))
add_child(T("people", lazy=False), to_gridPanel(db.people))
add_child(T("people_categories", lazy=False),
to_grid(db.people_categories))
add_child(
T("people_categories", lazy=False),
to_gridPanel(db.people_categories))
add_child(T("objects", lazy=False), to_grid(db.objects))
add_child(T("objects", lazy=False), to_gridPanel(db.objects))
add_child(T("object_categories", lazy=False),
to_grid(db.object_categories))
add_child(
T("object_categories", lazy=False),
to_gridPanel(db.object_categories))
node.sort_children()
......@@ -306,4 +312,3 @@ class ViewportUi(object):
add_child(source, panel)
return node
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