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

Add the wizard node with its two leaves (trainee and person)and their

controllers
parent 68ea9c23
......@@ -56,9 +56,6 @@ def people():
# instantiate the selector
selector = MySelector(virtdb.people_selector)
# add constraint to avoid 'stagiaire' category
selector.append_query(db.categories.category != 'stagiaire')
# add constraint to avoid event (phd, hdr, ...)
selector.append_query(db.history.id_events == undef_id)
......
""" Wizard controllers
"""
import traceback
from plugin_dbui import get_id
from reporting_tools import MySelector
def person():
# instenciate the selector
selector = MySelector(virtdb.person_wizard)
try:
# people section
id_people = get_id(db.people,
first_name=selector.first_name,
last_name=selector.last_name)
if id_people != None:
return T("The person exists in the database. "
"Modify the history table instead.")
id_people = db.people.insert(first_name=selector.first_name,
last_name=selector.last_name,
initials=selector.intials,
birth_date=selector.birth_date)
# history section
db.history.insert(id_people=id_people,
id_teams=selector.id_teams,
id_project=selector.id_projects,
id_categories=selector.id_categories,
start_date=selector.start_date,
end_date=selector.end_date)
return T("Add a new person successfully")
except BaseException, e:
msg = '<br><br><hr/>'
msg += CODE(traceback.format_exc()).xml()
msg += '<hr/>'
return msg
def trainee():
# instenciate the selector
selector = MySelector(virtdb.trainee_wizard)
try:
# people section
id_people = get_id(db.people,
first_name=selector.first_name,
last_name=selector.last_name)
if id_people == None:
initials = selector.first_name[0]+selector.last_name[0]
id_people = db.people.insert(first_name=selector.first_name,
last_name=selector.last_name,
initials=initials,
birth_date=selector.birth_date)
# people category
id_category = get_id(db.categories, code=selector.stage_level)
# history section
id = db.history.insert(id_people=id_people,
id_teams=selector.id_teams,
id_projects=selector.id_projects,
id_categories=id_category,
start_date=selector.start_date,
end_date=selector.end_date,
cdd_flag=True,
percentage=100,
stage_title=selector.stage_title,
stage_university=selector.stage_university,
stage_category=selector.stage_category)
return T("Add a new history line %i") % id
except BaseException, e:
msg = '<br><br><hr/>'
msg += CODE(traceback.format_exc()).xml()
msg += '<hr/>'
return msg
......@@ -3,6 +3,9 @@
'%s between %s and %s': '%s du %s au %s',
'%s in %s': '%s en %s',
'%Y-%m-%d': '%Y-%m-%d',
'Add a new history line %i': 'Add a new history line %i',
'Add person': 'Ajouter une personne',
'Add trainee': 'Ajouter un stagiaire',
'Age': 'Age',
'Agencies': 'Agences',
'agencies': 'agences',
......@@ -139,6 +142,7 @@
'Usual': 'Habituel',
'value already in database or empty': 'value already in database or empty',
'versions': 'versions',
'Wizards': 'Assistants',
'Year': 'Année',
'Year End': 'Year End',
'Year Start': 'Year Start',
......
......@@ -74,6 +74,29 @@ IS_IN_DB(db, 'teams.id', 'teams.team')
virtdb.people_selector.format.requires = IS_IN_SET(['html'])
#
# person wizard
#
virtdb.define_table('person_wizard',
Field("first_name", "string"),
Field("last_name", "string"),
Field("initials", "string"),
Field("birth_date", "date"),
Field("start_date", "date"),
Field("end_date", "date"),
Field("id_categories", db.categories, default=undef_id, label='Category'),
Field("id_teams", db.teams, default=undef_id, label='Team'),
Field("id_projects", db.projects, default=undef_id, label='Project'))
virtdb.person_wizard.id_categories.requires = \
IS_IN_DB(db, 'categories.id', 'categories.code')
virtdb.person_wizard.id_projects.requires = \
IS_IN_DB(db, 'projects.id', 'projects.project')
virtdb.person_wizard.id_teams.requires = \
IS_IN_DB(db, 'teams.id', 'teams.team')
#
# responsibilities selector
#
......@@ -92,3 +115,33 @@ virtdb.responsibilities_selector.id_organizations.requires = \
IS_IN_DB(db, 'organizations.id', 'orgainzations.level')
virtdb.responsibilities_selector.format.requires = IS_IN_SET(['html', 'csv'])
#
# trainee wizard
#
virtdb.define_table('trainee_wizard',
Field("first_name", "string"),
Field("last_name", "string"),
Field("birth_date", "date"),
Field("start_date", "date"),
Field("end_date", "date"),
Field("stage_level", "string", label=T("Level")),
Field("stage_title", "text", label=T('Title')),
Field("stage_university", "text", label=T('University')),
Field("stage_category", "string", default='PHY', label=T("Category")),
Field("id_teams", db.teams, default=undef_id, label='Team'),
Field("id_projects", db.projects, default=undef_id, label='Project'))
virtdb.trainee_wizard.id_projects.requires = \
IS_IN_DB(db, 'projects.id', 'projects.project')
virtdb.trainee_wizard.id_teams.requires = \
IS_IN_DB(db, 'teams.id', 'teams.team')
virtdb.trainee_wizard.stage_category.requires = \
IS_IN_SET(('PHY', 'IR'))
rows = db(db.categories.category=='stagiaire').select(db.categories.code)
virtdb.trainee_wizard.stage_level.requires = \
IS_IN_SET((el.code for el in rows))
......@@ -63,6 +63,7 @@ gridModifier.hide_columns('cdd_flag',
'note',
'percentage',
'responsibility',
'stage_category',
'stage_title',
'stage_university')
gridModifier.set_rownumbering()
......
......@@ -3,50 +3,63 @@
"""
#
# The grid node for the navigation tree
# grid node
#
gridNode = dbui.Node(T('Tables'))
configurator = lambda tablename: dbui.to_gridPanel(db[tablename])
gridNode.add_children(db.tables, func=configurator)
#
# the report node
# report node
#
peopleNode = dbui.to_panelWithUrlSelector(virtdb.people_selector,
peopleLeaf = dbui.to_panelWithUrlSelector(virtdb.people_selector,
baseUrl=URL('list', 'people'))
hardwareNode = dbui.to_panelWithUrlSelector(virtdb.hardware_selector,
hardwareLeaf = dbui.to_panelWithUrlSelector(virtdb.hardware_selector,
baseUrl=URL('list', 'hardware'))
historyNode = dbui.to_panelWithUrlSelector(virtdb.history_selector,
historyLeaf = dbui.to_panelWithUrlSelector(virtdb.history_selector,
baseUrl=URL('list', 'history'))
respNode = dbui.to_panelWithUrlSelector(virtdb.responsibilities_selector,
respLeaf = dbui.to_panelWithUrlSelector(virtdb.responsibilities_selector,
baseUrl=URL('list', 'responsibilities'))
reportNode = dbui.Node(T('Reports'))
reportNode.add_child(T('History'), historyNode)
reportNode.add_child(T('List of hardware'), hardwareNode)
reportNode.add_child(T('List of people'), peopleNode)
reportNode.add_child(T('List of responsibilities'), respNode)
reportNode.add_child(T('History'), historyLeaf)
reportNode.add_child(T('List of hardware'), hardwareLeaf)
reportNode.add_child(T('List of people'), peopleLeaf)
reportNode.add_child(T('List of responsibilities'), respLeaf)
reportNode.sort_children()
#
# The tool node for the navigation tree
# tool node
#
schemaNode = dbui.Panel(autoLoad=URL('default', 'schema'))
versionNode = dbui.Panel(autoLoad=URL('default', 'versions'))
schemaLeaf = dbui.Panel(autoLoad=URL('default', 'schema'))
versionLeaf = dbui.Panel(autoLoad=URL('default', 'versions'))
helpNode = dbui.Node(T('Help'))
helpNode.add_child(T('database schema'), schemaNode)
helpNode.add_child(T('versions'), versionNode)
helpNode.add_child(T('database schema'), schemaLeaf)
helpNode.add_child(T('versions'), versionLeaf)
helpNode.sort_children()
#
# Wizards node
#
personLeaf = dbui.to_panelWithUrlSelector(virtdb.person_wizard,
baseUrl=URL('wizard', 'person'))
traineeLeaf = dbui.to_panelWithUrlSelector(virtdb.trainee_wizard,
baseUrl=URL('wizard', 'trainee'))
wizardNode = dbui.Node(T('Wizards'))
wizardNode.add_child(T('Add person'), personLeaf)
wizardNode.add_child(T('Add trainee'), traineeLeaf)
#
# The viewport with its navigation tree
#
viewportModifier = dbui.ViewportModifier()
viewportModifier.add_node(helpNode, gridNode, reportNode)
viewportModifier.add_node(helpNode, wizardNode, gridNode, reportNode)
......@@ -4,7 +4,9 @@ HEAD
- Migrate to plugin_dbui 0.4.9.1 to develop filter on date.
- Add the class MySelector, Base, Hardware and Person.
- Build the list of history, hardware and people.
- Improve the database schema introducing the concept of events.
- Simplify the database schema introducing the concept of events
removing hardware and responsibilities tables.
- Add a new node wizard to enter person and training
- Polish the interface
0.1.0 (July 2012)
......
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