From 3665f526e2fef8d1b120bd3f6743b5c4b0c0c45e Mon Sep 17 00:00:00 2001 From: legac <renaud.legac@free.fr> Date: Sat, 6 Oct 2012 12:22:08 +0200 Subject: [PATCH] Improved files organization for the database model. --- models/{db.py => db_core.py} | 75 +++++++++--------------------------- models/db_tools.py | 45 ++++++++++++++++++++++ static/plugin_dbui/CHANGELOG | 3 +- 3 files changed, 66 insertions(+), 57 deletions(-) rename models/{db.py => db_core.py} (71%) create mode 100644 models/db_tools.py diff --git a/models/db.py b/models/db_core.py similarity index 71% rename from models/db.py rename to models/db_core.py index 6aaf29a9..4649e14e 100644 --- a/models/db.py +++ b/models/db_core.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -""" db +""" db core - Defined the database tables for your applications. + Core tables for the application. """ import locale @@ -46,79 +46,41 @@ year = datetime.now().year #------------------------------------------------------------------------------- # -# basic tables +# core tables # #------------------------------------------------------------------------------- db.define_table("categories", Field("code", "string", notnull=True, unique=True), - Field("definition", "text", notnull=True)) + Field("definition", "text", notnull=True), + migrate="categories.table") db.categories.code.requires = IS_MATCH('^[0-9]+$') db.define_table("collaborations", - Field("collaboration", "string", notnull=True, unique=True)) + Field("collaboration", "string", notnull=True, unique=True), + migrate="collaborations.table") db.define_table("countries", Field("country", "string", notnull=True, unique=True), - Field("abbreviation", "string", notnull=True)) + Field("abbreviation", "string", notnull=True), + migrate="countries.table") db.define_table("projects", - Field("project", "string", notnull=True, unique=True)) + Field("project", "string", notnull=True, unique=True), + migrate="projects.table") db.define_table("publishers", Field("publisher", "string", notnull=True, unique=True), - Field("abbreviation", "string", notnull=True)) + Field("abbreviation", "string", notnull=True), + migrate="publishers.table") db.define_table("reports", - Field("type", "string", notnull=True, unique=True)) + Field("type", "string", notnull=True, unique=True), + migrate="reports.table") db.define_table("teams", - Field("team", "string", notnull=True, unique=True)) - -#------------------------------------------------------------------------------- -# -# technical tables -# -#------------------------------------------------------------------------------- -tp_category = \ -"Publication category associated to the record." - -tp_collections = \ -"List of collections separated by commma: LHCb Papers, LHCb Talks" - -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." - -tp_max_records = \ -"Maximum number of records which can be retrieved from a search." - -tp_ratio = \ -"Parameter for fuzzy string search." - -db.define_table("harvesters", - Field("id_teams", db.teams, default=undef_id, 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=undef_id, label='Category', comment=tp_category)) - -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.harvesters.id_teams.requires = \ -IS_IN_DB(db, 'teams.id', 'teams.team') - -db.harvesters.ratio.requires = \ -IS_FLOAT_IN_RANGE(0., 1.0) - + Field("team", "string", notnull=True, unique=True), + migrate="teams.table") #------------------------------------------------------------------------------- # @@ -162,7 +124,8 @@ db.define_table("publications", Field("authors_cppm", "text", notnull=True, comment=tp_authors_cppm), Field("id_teams", db.teams, default=undef_id, label='Team'), Field("id_projects", db.projects, default=undef_id, label='Projects'), - Field("id_categories", db.categories, default=undef_id, label='AERES')) + Field("id_categories", db.categories, default=undef_id, label='AERES'), + migrate="publications.table") db.publications.id_categories.requires = \ IS_IN_DB(db, 'categories.id', 'categories.code') diff --git a/models/db_tools.py b/models/db_tools.py new file mode 100644 index 00000000..3c58eb22 --- /dev/null +++ b/models/db_tools.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +""" db tools + + Configuration tables for the application tools. + +""" +tp_category = \ +"Publication category associated to the record." + +tp_collections = \ +"List of collections separated by commma: LHCb Papers, LHCb Talks" + +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." + +tp_max_records = \ +"Maximum number of records which can be retrieved from a search." + +tp_ratio = \ +"Parameter for fuzzy string search." + +db.define_table("harvesters", + Field("id_teams", db.teams, default=undef_id, 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=undef_id, label='Category', comment=tp_category), + migrate="harvesters.table") + +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.harvesters.id_teams.requires = \ +IS_IN_DB(db, 'teams.id', 'teams.team') + +db.harvesters.ratio.requires = \ +IS_FLOAT_IN_RANGE(0., 1.0) \ No newline at end of file diff --git a/static/plugin_dbui/CHANGELOG b/static/plugin_dbui/CHANGELOG index 795f9d7f..314e3174 100644 --- a/static/plugin_dbui/CHANGELOG +++ b/static/plugin_dbui/CHANGELOG @@ -1,7 +1,8 @@ --------------------------------- CHANGE LOG ---------------------------------- HEAD - - Improve grid filter namely by adding the method append_filter. + - New syntax for grid filter via the method GridModifier.append_filter. + - Improve the files organization defining the model. - Enable tab scrolling in viewport. 0.4.8.2 (Jul 2012) -- GitLab