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

First implementation.

parent adc85109
doc/database.png

99 KB | W: | H:

doc/database.png

98.2 KB | W: | H:

doc/database.png
doc/database.png
doc/database.png
doc/database.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -22,4 +22,4 @@
<type label="Upload" length="0" sql="upload" quote="'"/>
<type label="Password" length="0" sql="password" quote="'"/>
</group>
</datatypes><table x="593" y="21" name="people"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="first_name" null="0" autoincrement="0"><datatype>string</datatype></row><row name="last_name" null="0" autoincrement="0"><datatype>string</datatype></row><row name="initials" null="0" autoincrement="0"><datatype>string</datatype></row><row name="birth_date" null="1" autoincrement="0"><datatype>date</datatype></row><row name="phd" null="1" autoincrement="0"><datatype>boolean</datatype></row><row name="hdr" null="1" autoincrement="0"><datatype>boolean</datatype></row><row name="phd_date" null="1" autoincrement="0"><datatype>date</datatype></row><row name="hdr_date" null="1" autoincrement="0"><datatype>integer</datatype></row><row name="note" null="1" autoincrement="0"><datatype>text</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table><table x="596" y="281" name="teams"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="team" null="0" autoincrement="0"><datatype>string</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table><table x="590" y="393" name="projects"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="project" null="0" autoincrement="0"><datatype>string</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table><table x="932" y="139" name="categories"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="category" null="0" autoincrement="0"><datatype>string</datatype></row><row name="grade" null="1" autoincrement="0"><datatype>string</datatype></row><row name="definition" null="1" autoincrement="0"><datatype>string</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table><table x="803" y="57" name="careers"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="id_person" null="0" autoincrement="0"><datatype>integer</datatype><relation table="people" row="id" /></row><row name="id_teams" null="0" autoincrement="0"><datatype>integer</datatype><relation table="teams" row="id" /></row><row name="id_projects" null="0" autoincrement="0"><datatype>integer</datatype><relation table="projects" row="id" /></row><row name="id_categories" null="0" autoincrement="0"><datatype>integer</datatype><relation table="categories" row="id" /></row><row name="start_date" null="0" autoincrement="0"><datatype>date</datatype></row><row name="end_date" null="1" autoincrement="0"><datatype>date</datatype></row><row name="percentage" null="1" autoincrement="0"><datatype>integer</datatype></row><row name="note" null="0" autoincrement="0"><datatype>text</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table><table x="327" y="56" name="responsabilities"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="id_people" null="1" autoincrement="0"><datatype>integer</datatype><relation table="people" row="id" /></row><row name="id_teams" null="1" autoincrement="0"><datatype>integer</datatype><relation table="teams" row="id" /></row><row name="id_projects" null="0" autoincrement="0"><datatype>integer</datatype><relation table="projects" row="id" /></row><row name="name" null="0" autoincrement="0"><datatype>string</datatype></row><row name="start_date" null="0" autoincrement="0"><datatype>date</datatype></row><row name="end_date" null="1" autoincrement="0"><datatype>date</datatype></row><row name="id_organisations" null="0" autoincrement="0"><datatype>integer</datatype><relation table="organisations" row="id" /></row><row name="id_levels" null="0" autoincrement="0"><datatype>integer</datatype><relation table="levels" row="id" /></row><row name="note" null="1" autoincrement="0"><datatype>text</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table><table x="348" y="316" name="hardware"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="id_people" null="0" autoincrement="0"><datatype>integer</datatype><relation table="people" row="id" /></row><row name="id_teams" null="0" autoincrement="0"><datatype>integer</datatype><relation table="teams" row="id" /></row><row name="id_projects" null="0" autoincrement="0"><datatype>integer</datatype><relation table="projects" row="id" /></row><row name="model" null="0" autoincrement="0"><datatype>string</datatype></row><row name="start_date" null="0" autoincrement="0"><datatype>date</datatype></row><row name="end_date" null="1" autoincrement="0"><datatype>date</datatype></row><row name="cost" null="1" autoincrement="0"><datatype>integer</datatype></row><row name="note" null="1" autoincrement="0"><datatype>text</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table><table x="109" y="154" name="organisations"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="organisation" null="0" autoincrement="0"><datatype>string</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table><table x="131" y="248" name="levels"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="level" null="0" autoincrement="0"><datatype>string</datatype></row><row name="definition" null="0" autoincrement="0"><datatype>string</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table><table x="807" y="316" name="budgets"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="id_people" null="0" autoincrement="0"><datatype>integer</datatype><relation table="people" row="id" /></row><row name="id_teams" null="0" autoincrement="0"><datatype>integer</datatype><relation table="teams" row="id" /></row><row name="id_projects" null="0" autoincrement="0"><datatype>integer</datatype><relation table="projects" row="id" /></row><row name="year" null="0" autoincrement="0"><datatype>integer</datatype></row><row name="line" null="1" autoincrement="0"><datatype>string</datatype></row><row name="demanded" null="1" autoincrement="0"><datatype>integer</datatype></row><row name="notified" null="1" autoincrement="0"><datatype>integer</datatype></row><row name="executed" null="1" autoincrement="0"><datatype>integer</datatype></row><row name="note" null="1" autoincrement="0"><datatype>text</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table></sql>
\ No newline at end of file
</datatypes><table x="593" y="21" name="people"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="first_name" null="0" autoincrement="0"><datatype>string</datatype></row><row name="last_name" null="0" autoincrement="0"><datatype>string</datatype></row><row name="initials" null="0" autoincrement="0"><datatype>string</datatype></row><row name="birth_date" null="1" autoincrement="0"><datatype>date</datatype></row><row name="phd" null="1" autoincrement="0"><datatype>boolean</datatype></row><row name="hdr" null="1" autoincrement="0"><datatype>boolean</datatype></row><row name="phd_date" null="1" autoincrement="0"><datatype>date</datatype></row><row name="hdr_date" null="1" autoincrement="0"><datatype>integer</datatype></row><row name="note" null="1" autoincrement="0"><datatype>text</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table><table x="596" y="281" name="teams"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="team" null="0" autoincrement="0"><datatype>string</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table><table x="590" y="393" name="projects"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="project" null="0" autoincrement="0"><datatype>string</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table><table x="932" y="139" name="categories"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="category" null="0" autoincrement="0"><datatype>string</datatype></row><row name="grade" null="1" autoincrement="0"><datatype>string</datatype></row><row name="definition" null="1" autoincrement="0"><datatype>string</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table><table x="803" y="57" name="careers"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="id_people" null="0" autoincrement="0"><datatype>integer</datatype><relation table="people" row="id" /></row><row name="id_teams" null="0" autoincrement="0"><datatype>integer</datatype><relation table="teams" row="id" /></row><row name="id_projects" null="0" autoincrement="0"><datatype>integer</datatype><relation table="projects" row="id" /></row><row name="id_categories" null="0" autoincrement="0"><datatype>integer</datatype><relation table="categories" row="id" /></row><row name="start_date" null="0" autoincrement="0"><datatype>date</datatype></row><row name="end_date" null="1" autoincrement="0"><datatype>date</datatype></row><row name="percentage" null="1" autoincrement="0"><datatype>integer</datatype></row><row name="note" null="0" autoincrement="0"><datatype>text</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table><table x="327" y="56" name="responsabilities"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="id_people" null="1" autoincrement="0"><datatype>integer</datatype><relation table="people" row="id" /></row><row name="id_teams" null="1" autoincrement="0"><datatype>integer</datatype><relation table="teams" row="id" /></row><row name="id_projects" null="0" autoincrement="0"><datatype>integer</datatype><relation table="projects" row="id" /></row><row name="name" null="0" autoincrement="0"><datatype>string</datatype></row><row name="start_date" null="0" autoincrement="0"><datatype>date</datatype></row><row name="end_date" null="1" autoincrement="0"><datatype>date</datatype></row><row name="id_organizations" null="0" autoincrement="0"><datatype>integer</datatype><relation table="organizations" row="id" /></row><row name="id_levels" null="0" autoincrement="0"><datatype>integer</datatype><relation table="levels" row="id" /></row><row name="note" null="1" autoincrement="0"><datatype>text</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table><table x="348" y="316" name="hardware"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="id_people" null="0" autoincrement="0"><datatype>integer</datatype><relation table="people" row="id" /></row><row name="id_teams" null="0" autoincrement="0"><datatype>integer</datatype><relation table="teams" row="id" /></row><row name="id_projects" null="0" autoincrement="0"><datatype>integer</datatype><relation table="projects" row="id" /></row><row name="model" null="0" autoincrement="0"><datatype>string</datatype></row><row name="start_date" null="0" autoincrement="0"><datatype>date</datatype></row><row name="end_date" null="1" autoincrement="0"><datatype>date</datatype></row><row name="cost" null="1" autoincrement="0"><datatype>integer</datatype></row><row name="note" null="1" autoincrement="0"><datatype>text</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table><table x="109" y="154" name="organizations"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="organization" null="0" autoincrement="0"><datatype>string</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table><table x="131" y="248" name="levels"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="level" null="0" autoincrement="0"><datatype>string</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table><table x="807" y="316" name="budgets"><row name="id" null="0" autoincrement="1"><datatype>integer</datatype></row><row name="id_people" null="0" autoincrement="0"><datatype>integer</datatype><relation table="people" row="id" /></row><row name="id_teams" null="0" autoincrement="0"><datatype>integer</datatype><relation table="teams" row="id" /></row><row name="id_projects" null="0" autoincrement="0"><datatype>integer</datatype><relation table="projects" row="id" /></row><row name="year" null="0" autoincrement="0"><datatype>integer</datatype></row><row name="line" null="1" autoincrement="0"><datatype>string</datatype></row><row name="demanded" null="1" autoincrement="0"><datatype>integer</datatype></row><row name="notified" null="1" autoincrement="0"><datatype>integer</datatype></row><row name="executed" null="1" autoincrement="0"><datatype>integer</datatype></row><row name="note" null="1" autoincrement="0"><datatype>text</datatype></row><key type="PRIMARY" name=""><part>id</part></key></table></sql>
\ No newline at end of file
......@@ -35,12 +35,14 @@ locale.setlocale(locale.LC_ALL, "fr_FR.UTF-8")
#-------------------------------------------------------------------------------
#
# set constants
# constants
#
#-------------------------------------------------------------------------------
now = datetime.now()
today = now.strftime("%Y-%m-%d")
undef = T(dbui.UNDEF)
undef_id = dbui.UNDEF_ID
year = datetime.now().year
year = now.year
#-------------------------------------------------------------------------------
#
......@@ -55,55 +57,131 @@ db = DAL('sqlite://storage.sqlite', migrate=True)
#
#-------------------------------------------------------------------------------
db.define_table("categories",
Field("code", "string", notnull=True, unique=True),
Field("definition", "text", notnull=True),
Field("category", "string", notnull=True, unique=True),
Field("grade", "string"),
Field("definition", "text"),
migrate="categories.table")
db.define_table("levels",
Field("level", "string", notnull=True, unique=True),
migrate="levels.table")
db.define_table("people",
Field("first_name", "string", notnull=True),
Field("last_name", "string", notnull=True),
Field("initials", "string", notnull=True),
Field("birth_date", "date"),
Field("phd", "boolean", default=False),
Field("hdr", "boolean", default=False),
Field("phd_date", "date"),
Field("hdr_date", "date"),
migrate="people.table")
db.define_table("organizations",
Field("organization", "string", notnull=True, unique=True),
migrate="organizations.table")
db.define_table("projects",
Field("project", "string", notnull=True, unique=True),
migrate="projects.table")
db.define_table("teams",
Field("team", "string", notnull=True, unique=True),
migrate="teams.table")
#-------------------------------------------------------------------------------
#
# technical tables
# core tables
#
#-------------------------------------------------------------------------------
tp_category = \
"Publication category associated to the record."
db.define_table("budgets",
Field("id_people", db.persons, default=undef_id, label='Person'),
Field("id_teams", db.teams, default=undef_id, label='Team'),
Field("id_projects", db.projects, default=undef_id, label='Project'),
Field("year", "integer", default=year, notnull=True),
Field("line", "string", notnull=True),
Field("demanded", "double"),
Field("notified", "double"),
Field("executed", "double"),
Field("note", "text"),
migrate="budgets.table")
db.budgets.id_people.requires = \
IS_IN_DB(db, 'people.id', 'people.last_name')
db.budgets.id_teams.requires = \
IS_IN_DB(db, 'teams.id', 'teams.team')
tp_collections = \
"List of collections separated by commma: LHCb Papers, LHCb Talks"
db.budgets.id_projects.requires = \
IS_IN_DB(db, 'projects.id', 'projects.project')
tp_controller = \
"The name of the web2py controller running the search: articles, proceedings,..."
tp_host = \
"Address of the invenio store where the search is performed."
db.define_table("careers",
Field("id_people", db.persons, default=undef_id, label='Person'),
Field("id_teams", db.teams, default=undef_id, label='Team'),
Field("id_projects", db.projects, default=undef_id, label='Project'),
Field("id_categories", db.categoriess, default=undef_id, label='Category'),
Field("start_date", "date", default=today, notnull=True),
Field("end_date", "date"),
Field("percentage", "integer", default=100),
Field("note", "text"),
migrate="categories.table")
tp_max_records = \
"Maximum number of records which can be retrieved from a search."
db.careers.id_people.requires = \
IS_IN_DB(db, 'people.id', 'people.last_name')
tp_ratio = \
"Parameter for fuzzy string search."
db.careers.id_teams.requires = \
IS_IN_DB(db, 'teams.id', 'teams.team')
db.define_table("harvesters",
Field("id_teams", db.teams, default=1, label='Team'),
Field("controller", "string", notnull=True, comment=tp_controller),
Field("host", "string", notnull=True, default='cdsweb.cern.ch', comment=tp_host),
Field("collections", "string", comment=tp_collections),
Field("max_records", "integer", notnull=True, default=200, comment=tp_max_records),
Field("ratio", "double", notnull=True, default=1.0, comment=tp_ratio),
Field("id_categories", db.categories, default=1, label='Category', comment=tp_category),
migrate="harvesters.table")
db.careers.id_projects.requires = \
IS_IN_DB(db, 'projects.id', 'projects.project')
db.harvesters.controller.requires = \
IS_IN_SET(['articles', 'proceedings', 'reports', 'talks'])
db.harvesters.id_categories.requires = \
IS_IN_DB(db, 'categories.id', 'categories.code')
db.define_table("hardware",
Field("id_people", db.persons, default=undef_id, label='Person'),
Field("id_teams", db.teams, default=undef_id, label='Team'),
Field("id_projects", db.projects, default=undef_id, label='Project'),
Field("model", "string"),
Field("start_date", "date", default=today, notnull=True),
Field("end_date", "date"),
Field("percentage", "integer", default=100),
Field("cost", "double"),
Field("note", "text"),
migrate="hardware.table")
db.harvesters.id_teams.requires = \
db.hardware.id_people.requires = \
IS_IN_DB(db, 'people.id', 'people.last_name')
db.hardware.id_teams.requires = \
IS_IN_DB(db, 'teams.id', 'teams.team')
db.harvesters.ratio.requires = \
IS_FLOAT_IN_RANGE(0., 1.0)
db.hardware.id_projects.requires = \
IS_IN_DB(db, 'projects.id', 'projects.project')
db.define_table("responsabilities",
Field("id_people", db.persons, default=undef_id, label='Person'),
Field("id_teams", db.teams, default=undef_id, label='Team'),
Field("id_projects", db.projects, default=undef_id, label='Project'),
Field("name", "string"),
Field("start_date", "date", default=today, notnull=True),
Field("end_date", "date"),
Field("id_organizations", db.organizations, default=undef_id, label='Organization'),
Field("id_levels", db.levels, default=undef_id, label='Level'),
Field("note", "text"),
migrate="responsabilities.table")
db.responsabilities.id_people.requires = \
IS_IN_DB(db, 'people.id', 'people.last_name')
db.responsabilities.id_teams.requires = \
IS_IN_DB(db, 'teams.id', 'teams.team')
db.responsabilities.id_projects.requires = \
IS_IN_DB(db, 'projects.id', 'projects.project')
db.responsabilities.id_organizations.requires = \
IS_IN_DB(db, 'organizations.id', 'organizations.organization')
db.responsabilities.id_levels.requires = \
IS_IN_DB(db, 'levels.id', 'levels.level')
......@@ -2,10 +2,24 @@
""" defaults
Insert defaults values in the tables
"""
if not db(db.categories.id).count():
db.categories.insert(id=undef_id, code=undef, definition=undef)
db.categories.insert(id=undef_id, category=undef, definition=undef)
if not db(db.levels.id).count():
db.levels.insert(id=undef_id, level=undef)
if not db(db.organizations.id).count():
db.organizations.insert(id=undef_id, organization=undef)
if not db(db.people.id).count():
db.people.insert(id=undef_id, first_name=undef,
last_name=undef,
initials=undef)
if not db(db.projects.id).count():
db.projects.insert(id=undef_id, project=undef)
if not db(db.teams.id).count():
db.teams.insert(id=undef_id, team=undef)
\ No newline at end of file
# -*- coding: utf-8 -*-
""" mydefaults
Defined constants specific to the track_org application.
It ease the cold start and can be removed at any time.
"""
if db(db.categories.id).count() == 1:
db.categories.insert(id=2, category='chercheur', grade='CR2')
db.categories.insert(id=3, category='chercheur', grade='CR1')
db.categories.insert(id=4, category='chercheur', grade='DR2')
db.categories.insert(id=5, category='chercheur', grade='DR1')
db.categories.insert(id=6, category='chercheur', grade='DR1')
db.categories.insert(id=7, category='chercheur', grade='POSTDOC')
db.categories.insert(id=8, category='doctorant', grade='MRT')
db.categories.insert(id=9, category='enseignant chercheur', grade='ATER')
db.categories.insert(id=10, category='enseignant chercheur', grade='MC')
db.categories.insert(id=11, category='enseignant chercheur', grade='PR')
db.categories.insert(id=12, category='ingénieur', grade='AI')
db.categories.insert(id=13, category='ingénieur', grade='IR2')
db.categories.insert(id=14, category='ingénieur', grade='IR1')
db.categories.insert(id=15, category='ingénieur', grade='IR0')
db.categories.insert(id=16, category='stagiaire', grade='L3')
db.categories.insert(id=17, category='stagiaire', grade='M1')
db.categories.insert(id=18, category='stagiaire', grade='M2')
if db(db.levels.id).count() == 1:
db.levels.insert(id=2, level='local')
db.levels.insert(id=3, level='national')
db.levels.insert(id=4, level='international')
if db(db.teams.id).count() == 1:
db.teams.insert(id=2, level='LHCb')
......@@ -2,27 +2,8 @@
""" virtdb
Defined tables in a virtual database.
They are used to build forms in order to generate url, ....
taking benefit of the web2py validators
NOTE: similar approach to the SQLFORM.factory
"""
virtdb = DAL(None)
They are used to build selector.
# harvester selector
virtdb.define_table('harvester_selector',
Field('year_start', 'integer', default=year),
Field('year_end', 'integer'),
Field('id_teams', db.teams, default=2, label='Team'),
Field('store', 'string', default='articles'))
virtdb.harvester_selector.id_teams.requires = IS_IN_DB(db,
'teams.id',
'teams.team')
"""
virtdb.harvester_selector.store.requires = IS_IN_SET(['articles',
'proceedings',
'reports',
'talks'])
virtdb = DAL(None)
\ No newline at end of file
......@@ -2,26 +2,17 @@
""" widgets
Customize forms and grids widgets
"""
#
# add plugins to all forms and grids
#
dbui.configure_grids(db, plugins=['pGridRowEditorConfirmDelete',
'pGridRowEditorContextMenu',
'pGridPaging',
'pGridMathJax'])
'pGridPaging'])
dbui.configure_forms(db, plugins=['pFormToolTip'])
#
# merge fields in the harvest_selector forms
#
fieldsModifier = dbui.FieldsModifier('harvester_selector')
fieldsModifier.configure_field('year_start', flex=1)
fieldsModifier.configure_field('year_end', flex=1)
fieldsModifier.merge_fields('year_start', 'year_end', fieldLabel=T('Year'))
#
# The form node of the navigation tree
#
......@@ -33,24 +24,13 @@ formNode.add_children(db.tables, func=configurator)
# The grid node of the navigation tree
#
gridNode = dbui.Node(T('Tables'))
configurator = lambda tablename: dbui.to_gridPanel(db[tablename])
gridNode.add_children(db.tables, func=configurator)
configurator = lambda tablename: dbui.to_gridPanel(db[tablename])
gridNode.add_children(db.tables, func=configurator)
#
# The tool node of the navigation tree
#
fields = dbui.to_fields(virtdb.harvester_selector)
selector = dbui.FieldSet(items=fields, plugins=['pFormToolTip'],
title=T('Select'))
harvesterNode = dbui.PanelWithUrlSelector(baseUrl='/'+request.application+'/harvest',
ctrlField='Harvester_selectorStore',
isMathJax=False,
panelCfg=dbui.Panel(),
selectorCfg=selector,
selectorCollapsible=False,
timeout=3600)
toolNode = dbui.Node(T('Tools'))
toolNode.add_child(T('harvesters'), harvesterNode)
toolNode.sort_children()
#
......
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