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 @@ ...@@ -2,12 +2,14 @@
"""Definitions of the core tables """Definitions of the core tables
""" """
import plugin_dbui as dbui
from callbacks import INHIBIT_CASCADE_DELETE from callbacks import INHIBIT_CASCADE_DELETE
from datetime import datetime from datetime import datetime
from gluon.validators import IS_IN_DB from gluon.validators import IS_IN_DB
from plugin_dbui import (INHIBIT_DELETE_UNDEF,
INHIBIT_UPDATE_UNDEF,
UNDEF_ID)
from pydal import Field from pydal import Field
...@@ -27,8 +29,8 @@ class Core(object): ...@@ -27,8 +29,8 @@ class Core(object):
""" """
table._before_delete.append(INHIBIT_CASCADE_DELETE) table._before_delete.append(INHIBIT_CASCADE_DELETE)
table._before_delete.append(dbui.INHIBIT_DELETE_UNDEF) table._before_delete.append(INHIBIT_DELETE_UNDEF)
table._before_update.append(dbui.INHIBIT_UPDATE_UNDEF) table._before_update.append(INHIBIT_UPDATE_UNDEF)
@staticmethod @staticmethod
def define_tables(db, T): def define_tables(db, T):
...@@ -134,7 +136,7 @@ class Core(object): ...@@ -134,7 +136,7 @@ class Core(object):
pyDAL.Table pyDAL.Table
""" """
undef_id = dbui.UNDEF_ID undef_id = UNDEF_ID
today = datetime.now().strftime("%Y-%m-%d") today = datetime.now().strftime("%Y-%m-%d")
table = db.define_table( table = db.define_table(
......
...@@ -2,14 +2,13 @@ ...@@ -2,14 +2,13 @@
"""User Interface for the core tables """User Interface for the core tables
""" """
import plugin_dbui as dbui
from gluon import current from gluon import current
from plugin_dbui import (FieldsModifier,
fieldsModifier = dbui.FieldsModifier FormModifier,
formModifier = dbui.FormModifier GridModifier,
gridModifier = dbui.GridModifier map_tabpanel,
storeModifier = dbui.StoreModifier StoreModifier,
UNDEF)
class CoreUi(object): class CoreUi(object):
...@@ -48,7 +47,7 @@ class CoreUi(object): ...@@ -48,7 +47,7 @@ class CoreUi(object):
# #
# Store # Store
# #
storeModifier("domains").orderby(db.domains.domain) StoreModifier("domains").orderby(db.domains.domain)
@staticmethod @staticmethod
def events(db, T): def events(db, T):
...@@ -63,7 +62,7 @@ class CoreUi(object): ...@@ -63,7 +62,7 @@ class CoreUi(object):
# #
# Fields # Fields
# #
mdf = fieldsModifier("events") mdf = FieldsModifier("events")
mdf.configure_field("data", mdf.configure_field("data",
colProperty={"width": 70}, colProperty={"width": 70},
colType={"width": 70}, colType={"width": 70},
...@@ -74,19 +73,19 @@ class CoreUi(object): ...@@ -74,19 +73,19 @@ class CoreUi(object):
# #
# Form # Form
# #
mdf = formModifier("events") mdf = FormModifier("events")
mdf.merge_fields("event", "definition", title=T("General")) mdf.merge_fields("event", "definition", title=T("General"))
mdf.merge_fields("data", title=T("Data model")) 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) mdf.configure(plugins=["pUserDataConsistency"], width=450)
# .................................................................... # ....................................................................
# #
# Grid # Grid
# #
mdf = gridModifier("events") mdf = GridModifier("events")
mdf.configure_column("event", width=30) mdf.configure_column("event", width=30)
mdf.hide_columns("data") mdf.hide_columns("data")
...@@ -109,7 +108,7 @@ class CoreUi(object): ...@@ -109,7 +108,7 @@ class CoreUi(object):
# #
# Store # Store
# #
storeModifier("events").orderby(db.events.event) StoreModifier("events").orderby(db.events.event)
@staticmethod @staticmethod
def fundings(db, T): def fundings(db, T):
...@@ -124,14 +123,14 @@ class CoreUi(object): ...@@ -124,14 +123,14 @@ class CoreUi(object):
# #
# Grid # Grid
# #
mdf = gridModifier("fundings") mdf = GridModifier("fundings")
mdf.configure_column("agency", width=40) mdf.configure_column("agency", width=40)
# .................................................................... # ....................................................................
# #
# Store # Store
# #
storeModifier("fundings").orderby(db.fundings.agency) StoreModifier("fundings").orderby(db.fundings.agency)
@staticmethod @staticmethod
def history(db, T): def history(db, T):
...@@ -142,13 +141,13 @@ class CoreUi(object): ...@@ -142,13 +141,13 @@ class CoreUi(object):
T (gluon.languages.translator): language translator T (gluon.languages.translator): language translator
""" """
undef = current.T(dbui.UNDEF) undef = current.T(UNDEF)
# .................................................................... # ....................................................................
# #
# Fields # Fields
# #
mdf = fieldsModifier("history") mdf = FieldsModifier("history")
mdf.configure_field("data", mdf.configure_field("data",
dictFieldData="EventsData", dictFieldData="EventsData",
...@@ -169,7 +168,7 @@ class CoreUi(object): ...@@ -169,7 +168,7 @@ class CoreUi(object):
# #
# Form # Form
# #
mdf = formModifier("history") mdf = FormModifier("history")
mdf.merge_fields("id_domains", mdf.merge_fields("id_domains",
"id_teams", "id_teams",
"id_projects", "id_projects",
...@@ -192,7 +191,7 @@ class CoreUi(object): ...@@ -192,7 +191,7 @@ class CoreUi(object):
mdf.merge_fields("note", title=T("Note")) mdf.merge_fields("note", title=T("Note"))
mdf.set_mapper(dbui.map_tabpanel) mdf.set_mapper(map_tabpanel)
mdf.configure(buttonAlign="right", width=450) mdf.configure(buttonAlign="right", width=450)
...@@ -200,7 +199,7 @@ class CoreUi(object): ...@@ -200,7 +199,7 @@ class CoreUi(object):
# #
# Grid # Grid
# #
mdf = gridModifier("history") mdf = GridModifier("history")
row_widget = { row_widget = {
"expandOnDblClick": False, "expandOnDblClick": False,
...@@ -261,7 +260,7 @@ class CoreUi(object): ...@@ -261,7 +260,7 @@ class CoreUi(object):
# #
# Store # Store
# #
storeModifier("history").orderby(~db.history.id) StoreModifier("history").orderby(~db.history.id)
@staticmethod @staticmethod
def object_categories(db, T): def object_categories(db, T):
...@@ -276,7 +275,7 @@ class CoreUi(object): ...@@ -276,7 +275,7 @@ class CoreUi(object):
# #
# Grid # Grid
# #
mdf = gridModifier("object_categories") mdf = GridModifier("object_categories")
mdf.configure_column("code", width=20) mdf.configure_column("code", width=20)
mdf.configure_column("category", width=20) mdf.configure_column("category", width=20)
...@@ -284,7 +283,7 @@ class CoreUi(object): ...@@ -284,7 +283,7 @@ class CoreUi(object):
# #
# Store # Store
# #
storeModifier("object_categories").orderby(db.object_categories.code) StoreModifier("object_categories").orderby(db.object_categories.code)
@staticmethod @staticmethod
def objects(db, T): def objects(db, T):
...@@ -299,7 +298,7 @@ class CoreUi(object): ...@@ -299,7 +298,7 @@ class CoreUi(object):
# #
# Grid # Grid
# #
mdf = gridModifier("objects") mdf = GridModifier("objects")
mdf.append_filter(("reference", "contains", T("contains"))) mdf.append_filter(("reference", "contains", T("contains")))
mdf.append_filter(("serial_number", "contains", T("contains"))) mdf.append_filter(("serial_number", "contains", T("contains")))
...@@ -311,7 +310,7 @@ class CoreUi(object): ...@@ -311,7 +310,7 @@ class CoreUi(object):
# #
# Store # Store
# #
storeModifier("objects").orderby(db.objects.reference) StoreModifier("objects").orderby(db.objects.reference)
@staticmethod @staticmethod
def people_categories(db, T): def people_categories(db, T):
...@@ -326,7 +325,7 @@ class CoreUi(object): ...@@ -326,7 +325,7 @@ class CoreUi(object):
# #
# Grid # Grid
# #
mdf = gridModifier("people_categories") mdf = GridModifier("people_categories")
mdf.configure_column("code", width=20) mdf.configure_column("code", width=20)
mdf.configure_column("category", width=20) mdf.configure_column("category", width=20)
...@@ -334,7 +333,7 @@ class CoreUi(object): ...@@ -334,7 +333,7 @@ class CoreUi(object):
# #
# Store # Store
# #
storeModifier("people_categories").orderby(db.people_categories.code) StoreModifier("people_categories").orderby(db.people_categories.code)
@staticmethod @staticmethod
def people(db, T): def people(db, T):
...@@ -349,7 +348,7 @@ class CoreUi(object): ...@@ -349,7 +348,7 @@ class CoreUi(object):
# #
# Grid # Grid
# #
mdf = gridModifier("people") mdf = GridModifier("people")
mdf.configure_column("birth_date", width=20) mdf.configure_column("birth_date", width=20)
mdf.configure_column("first_name", width=30) mdf.configure_column("first_name", width=30)
mdf.configure_column("initials", width=15) mdf.configure_column("initials", width=15)
...@@ -365,7 +364,7 @@ class CoreUi(object): ...@@ -365,7 +364,7 @@ class CoreUi(object):
# #
# Store # Store
# #
storeModifier("people").orderby(db.people.last_name) StoreModifier("people").orderby(db.people.last_name)
@staticmethod @staticmethod
def projects(db, T): def projects(db, T):
...@@ -380,14 +379,14 @@ class CoreUi(object): ...@@ -380,14 +379,14 @@ class CoreUi(object):
# #
# Grid # Grid
# #
mdf = gridModifier("projects") mdf = GridModifier("projects")
mdf.configure_column("project", width=20) mdf.configure_column("project", width=20)
# .................................................................... # ....................................................................
# #
# Store # Store
# #
storeModifier("projects").orderby(db.projects.project) StoreModifier("projects").orderby(db.projects.project)
@staticmethod @staticmethod
def teams(db, T): def teams(db, T):
...@@ -402,11 +401,11 @@ class CoreUi(object): ...@@ -402,11 +401,11 @@ class CoreUi(object):
# #
# Grid # Grid
# #
mdf = gridModifier("teams") mdf = GridModifier("teams")
mdf.configure_column("team", width=20) mdf.configure_column("team", width=20)
# .................................................................... # ....................................................................
# #
# Store # Store
# #
storeModifier("teams").orderby(db.teams.team) StoreModifier("teams").orderby(db.teams.team)
...@@ -2,13 +2,11 @@ ...@@ -2,13 +2,11 @@
"""User Interface for the report tables """User Interface for the report tables
""" """
import plugin_dbui as dbui from plugin_dbui import (FieldsModifier,
FormModifier,
GridModifier,
fieldsModifier = dbui.FieldsModifier map_tabpanel,
formModifier = dbui.FormModifier StoreModifier)
gridModifier = dbui.GridModifier
storeModifier = dbui.StoreModifier
COLUMN_GUIDE = "All columns will be configured when the field is empty" COLUMN_GUIDE = "All columns will be configured when the field is empty"
...@@ -56,7 +54,7 @@ class ReportUi(object): ...@@ -56,7 +54,7 @@ class ReportUi(object):
# #
# Fields # Fields
# #
mdf = fieldsModifier("lists2") mdf = FieldsModifier("lists2")
mdf.configure_field("columns", mdf.configure_field("columns",
editorHeight=240, editorHeight=240,
...@@ -101,7 +99,7 @@ class ReportUi(object): ...@@ -101,7 +99,7 @@ class ReportUi(object):
# #
# Form # Form
# #
mdf = formModifier("lists2") mdf = FormModifier("lists2")
mdf.merge_fields("name", mdf.merge_fields("name",
"title", "title",
...@@ -125,14 +123,14 @@ class ReportUi(object): ...@@ -125,14 +123,14 @@ class ReportUi(object):
"summary_all", "summary_all",
title=T("Summary")) title=T("Summary"))
mdf.set_mapper(dbui.map_tabpanel) mdf.set_mapper(map_tabpanel)
mdf.configure(width=450) mdf.configure(width=450)
# .................................................................... # ....................................................................
# #
# Grid # Grid
# #
mdf = gridModifier("lists2") mdf = GridModifier("lists2")
mdf.configure_column("name", width=30) mdf.configure_column("name", width=30)
mdf.hide_columns("columns", mdf.hide_columns("columns",
"conditions", "conditions",
...@@ -151,7 +149,7 @@ class ReportUi(object): ...@@ -151,7 +149,7 @@ class ReportUi(object):
# #
# Store # Store
# #
storeModifier("lists2").orderby(db.lists2.name) StoreModifier("lists2").orderby(db.lists2.name)
@staticmethod @staticmethod
def metrics2d2(db, T): def metrics2d2(db, T):
...@@ -166,7 +164,7 @@ class ReportUi(object): ...@@ -166,7 +164,7 @@ class ReportUi(object):
# #
# Fields # Fields
# #
mdf = fieldsModifier("metrics2d2") mdf = FieldsModifier("metrics2d2")
mdf.configure_field("definition", height=110) mdf.configure_field("definition", height=110)
...@@ -202,7 +200,7 @@ class ReportUi(object): ...@@ -202,7 +200,7 @@ class ReportUi(object):
# #
# Form # Form
# #
mdf = formModifier("metrics2d2") mdf = FormModifier("metrics2d2")
mdf.merge_fields("name", mdf.merge_fields("name",
"title", "title",
...@@ -228,14 +226,14 @@ class ReportUi(object): ...@@ -228,14 +226,14 @@ class ReportUi(object):
mdf.merge_fields("graph", mdf.merge_fields("graph",
title=T("Graph")) title=T("Graph"))
mdf.set_mapper(dbui.map_tabpanel) mdf.set_mapper(map_tabpanel)
mdf.configure(width=450) mdf.configure(width=450)
# .................................................................... # ....................................................................
# #
# Grid # Grid
# #
mdf = gridModifier("metrics2d2") mdf = GridModifier("metrics2d2")
mdf.configure_column("name", width=30) mdf.configure_column("name", width=30)
mdf.hide_columns("aggregate_func_z", mdf.hide_columns("aggregate_func_z",
"eval", "eval",
...@@ -254,4 +252,4 @@ class ReportUi(object): ...@@ -254,4 +252,4 @@ class ReportUi(object):
# #
# Store # Store
# #
storeModifier("metrics2d2").orderby(db.metrics2d2.name) StoreModifier("metrics2d2").orderby(db.metrics2d2.name)
...@@ -4,13 +4,11 @@ ...@@ -4,13 +4,11 @@
""" """
from gluon.html import URL from gluon.html import URL
from gluon.storage import Storage from gluon.storage import Storage
import plugin_dbui as dbui from plugin_dbui import (FieldsModifier,
FieldSet,
map_tabpanel,
fieldsModifier = dbui.FieldsModifier PanelWithUrlSelector,
formModifier = dbui.FormModifier to_fields)
gridModifier = dbui.GridModifier
storeModifier = dbui.StoreModifier
class SelectorUi(object): class SelectorUi(object):
...@@ -47,7 +45,7 @@ class SelectorUi(object): ...@@ -47,7 +45,7 @@ class SelectorUi(object):
# #
# Fields # Fields
# #
mdf = fieldsModifier("selector_list") mdf = FieldsModifier("selector_list")
mytype = "xcomboboxuserreset" mytype = "xcomboboxuserreset"
text = T("select...") text = T("select...")
...@@ -105,7 +103,7 @@ class SelectorUi(object): ...@@ -105,7 +103,7 @@ class SelectorUi(object):
# map between field name and field configuration # map between field name and field configuration
# keys are the field name or field label for merge fields # keys are the field name or field label for merge fields
mapfields = Storage() 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) key = (cfgfield.name if cfgfield.name else cfgfield.fieldLabel)
mapfields[key] = cfgfield mapfields[key] = cfgfield
...@@ -157,7 +155,7 @@ class SelectorUi(object): ...@@ -157,7 +155,7 @@ class SelectorUi(object):
] ]
# wrap fields within a FieldSet # wrap fields within a FieldSet
fieldset1 = dbui.FieldSet( fieldset1 = FieldSet(
defaults=dict(frame=True, layout="form"), defaults=dict(frame=True, layout="form"),
items=items, items=items,
layout="anchor", layout="anchor",
...@@ -165,9 +163,9 @@ class SelectorUi(object): ...@@ -165,9 +163,9 @@ class SelectorUi(object):
title=T("Select")) title=T("Select"))
# configure the PanelWithUrlSelector # configure the PanelWithUrlSelector
selector_panel = dbui.PanelWithUrlSelector( select