Commit 56d1b310 authored by legac's avatar legac
Browse files

Polish the naming scheme of the files defining the models.

parent 60aebec2
# -*- coding: utf-8 -*-
""" categories
"""
tp_code = "The code has to be in upper case."
db.define_table("categories",
Field("code", "string", comment=tp_code, notnull=True, unique=True),
Field("definition", "text", notnull=True),
migrate="categories.table")
db.categories.code.requires = IS_MATCH('^[A-Z]+$')
\ No newline at end of file
# -*- coding: utf-8 -*-
""" Collaborations
"""
db.define_table("collaborations",
Field("collaboration", "string", notnull=True, unique=True),
migrate="collaborations.table")
\ No newline at end of file
# -*- coding: utf-8 -*-
""" countries
"""
db.define_table("countries",
Field("country", "string", notnull=True, unique=True),
Field("abbreviation", "string", notnull=True),
migrate="countries.table")
db.countries._before_delete.append(country_delete)
db.countries._before_insert.append(country_insert)
db.countries._before_update.append(country_update)
\ No newline at end of file
# -*- coding: utf-8 -*-
""" harvesters
"""
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", "reference teams", default=undef_id, label='Team'),
Field("id_projects", "reference projects", default=undef_id, label='Project'),
Field("controller", "string", notnull=True, comment=tp_controller),
Field("host", "string", notnull=True, default='cdsweb.cern.ch', label='Store', comment=tp_host),
Field("collections", "string", comment=tp_collections),
Field("ratio", "double", notnull=True, default=1.0, comment=tp_ratio),
Field("id_categories", "reference categories", default=1, label='Category', comment=tp_category),
migrate="harvesters.table")
db.harvesters.controller.requires = \
IS_IN_SET(['articles', 'notes', 'preprints', 'proceedings', 'reports', 'talks', 'theses'])
# TEST THE DIFFERENT SYNTAX DEFINING FOREIGN KEY
db.harvesters.id_categories.requires = \
IS_IN_DB(db, 'categories.id', 'categories.code')
db.harvesters.id_projects.requires = \
IS_IN_DB(db, 'projects.project')
#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
# -*- coding: utf-8 -*-
""" new_fields
"""
db.define_table("new_fields",
Field("string", "string"),
Field("list_string", "list:string"),
Field("dictionary", "json"),
Field("python_code", "text"),
migrate="new_fields.table")
# NOTE: if we remove the json validator its seem to work ?
db.new_fields.dictionary.requires = None
\ No newline at end of file
# -*- coding: utf-8 -*-
""" projects
"""
db.define_table("projects",
Field("project", "string", notnull=True, unique=True),
migrate="projects.table")
\ No newline at end of file
# -*- coding: utf-8 -*-
""" publications
"""
tp_authors = \
"""List of authors separated by commma: J. Doe, P.-Y. Smith
For large collaboration the first author followed by et al.: J. Doe et al."""
tp_authors_cppm = \
"""List of authors separated by comma: P.-Y. Doe, J. Smith"""
tp_first = "first page"
tp_last = "last_page"
tp_report_numbers = \
"""List of report identifier separated by comma:
LHCb-PROC-2008-04, arXiv:0906.1516 """
tp_speaker = \
"""The name of the speaker: P.-Y. Smith"""
db.define_table("publications",
Field("title", "text", notnull=True),
Field("authors", "string", notnull=True, comment=tp_authors),
Field("id_collaborations", 'reference collaborations', default=undef_id, label="Collaboration"),
Field("id_publishers", 'reference publishers', default=undef_id, label="Publisher"),
Field("year", "integer", notnull=True, default=year, requires=IS_INT_IN_RANGE(1900, year+1)),
Field("doi", "string"),
Field("volume", "integer", requires=IS_EMPTY_OR(IS_INT_IN_RANGE(1, None))),
Field("first_page", "integer", requires=IS_EMPTY_OR(IS_INT_IN_RANGE(1, None)), comment=tp_first),
Field("last_page", "integer", requires=IS_EMPTY_OR(IS_INT_IN_RANGE(1, None)), comment=tp_last),
Field("e_print", "string", requires=IS_EMPTY_OR(IS_URL())),
Field("conference_title", "text", label='Title'),
Field("conference_url", "string", label='url', requires=IS_EMPTY_OR(IS_URL())),
Field("conference_start", "date", label='Start date'),
Field("conference_end", "date", label='End date'),
Field("conference_town", "string", label='Town'),
Field("id_countries", 'reference countries', default=undef_id, label='Country'),
Field("conference_speaker", "string", label='Speaker', comment=tp_speaker),
Field("report_numbers", "string", comment=tp_report_numbers),
Field("id_reports", 'reference reports', default=undef_id, label="Report type"),
Field("authors_cppm", "text", notnull=True, comment=tp_authors_cppm),
Field("id_teams", 'reference teams', default=undef_id, label='Team'),
Field("id_projects", 'reference projects', default=undef_id, label='Projects'),
Field("id_categories", 'reference categories', default=undef_id, label='AERES'),
migrate="publications.table")
db.publications.id_categories.requires = \
IS_IN_DB(db, 'categories.id', 'categories.code')
db.publications.id_collaborations.requires = \
IS_IN_DB(db, 'collaborations.id', 'collaborations.collaboration')
db.publications.id_countries.requires = \
IS_IN_DB(db, 'countries.id', 'countries.country')
db.publications.id_publishers.requires = \
IS_IN_DB(db, 'publishers.id', 'publishers.abbreviation')
db.publications.id_projects.requires = \
IS_IN_DB(db, 'projects.id', 'projects.project')
db.publications.id_reports.requires = \
IS_IN_DB(db, 'reports.id', 'reports.type')
db.publications.id_teams.requires = \
IS_IN_DB(db, 'teams.id', 'teams.team')
\ No newline at end of file
# -*- coding: utf-8 -*-
""" publishers
"""
db.define_table("publishers",
Field("publisher", "string", notnull=True, unique=True),
Field("abbreviation", "string", notnull=True),
migrate="publishers.table")
\ No newline at end of file
# -*- coding: utf-8 -*-
""" reports
"""
db.define_table("reports",
Field("type", "string", notnull=True, unique=True),
migrate="reports.table")
\ No newline at end of file
# -*- coding: utf-8 -*-
""" teams
"""
db.define_table("teams",
Field("team", "string", notnull=True, unique=True),
migrate="teams.table")
db.teams.team.filter_in = dbui.CLEAN_SPACES
\ No newline at end of file
# -*- coding: utf-8 -*-
""" categories table and associated widgets
""" categories widgets
"""
#-------------------------------------------------------------------------------
#
# DEFINITION
#
#-------------------------------------------------------------------------------
tp_code = "The code has to be in upper case."
db.define_table("categories",
Field("code", "string", comment=tp_code, notnull=True, unique=True),
Field("definition", "text", notnull=True),
migrate="categories.table")
db.categories.code.requires = IS_MATCH('^[A-Z]+$')
#-------------------------------------------------------------------------------
#
# STORE CONFIGURATiON
#
#-------------------------------------------------------------------------------
# example of buffered store
#
# storeModifier = dbui.StoreModifier('categories')
# storeModifier.set_buffered()
#-------------------------------------------------------------------------------
#
# FIELDS CONFIGURATiON
......@@ -63,3 +38,14 @@ gridModifier.configure_gridWithFilter(selectorTitle= 'MyFoo')
# leadingBufferZone=0,
# trailingBufferZone=0)
# gridModifier.append_plugins(plugin)
#-------------------------------------------------------------------------------
#
# STORE CONFIGURATiON
#
#-------------------------------------------------------------------------------
# example of buffered store
#
# storeModifier = dbui.StoreModifier('categories')
# storeModifier.set_buffered()
# -*- coding: utf-8 -*-
""" Collaborations table and associated widgets
""" Collaborations widgets
"""
#-------------------------------------------------------------------------------
#
# DEFINITION
#
#-------------------------------------------------------------------------------
db.define_table("collaborations",
Field("collaboration", "string", notnull=True, unique=True),
migrate="collaborations.table")
#-------------------------------------------------------------------------------
#
# STORE CONFIGURATiON
# FIELDS CONFIGURATiON
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
# FIELDS CONFIGURATiON
# FORM CONFIGURATiON
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
# FORM CONFIGURATiON
# GRID CONFIGURATiON
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
# GRID CONFIGURATiON
# STORE CONFIGURATiON
#
#-------------------------------------------------------------------------------
# -*- coding: utf-8 -*-
""" countries table and associated widgets
""" countries widgets
"""
#-------------------------------------------------------------------------------
#
# DEFINITION
#
#-------------------------------------------------------------------------------
db.define_table("countries",
Field("country", "string", notnull=True, unique=True),
Field("abbreviation", "string", notnull=True),
migrate="countries.table")
db.countries._before_delete.append(country_delete)
db.countries._before_insert.append(country_insert)
db.countries._before_update.append(country_update)
#-------------------------------------------------------------------------------
#
# STORE CONFIGURATiON
# FIELDS CONFIGURATiON
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
# FIELDS CONFIGURATiON
# FORM CONFIGURATiON
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
# FORM CONFIGURATiON
# GRID CONFIGURATiON
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
# GRID CONFIGURATiON
# STORE CONFIGURATiON
#
#-------------------------------------------------------------------------------
# -*- coding: utf-8 -*-
""" harvesters table and associated widgets
""" harvesters widgets
"""
#-------------------------------------------------------------------------------
#
# DEFINITION
#
#-------------------------------------------------------------------------------
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", "reference teams", default=undef_id, label='Team'),
Field("id_projects", "reference projects", default=undef_id, label='Project'),
Field("controller", "string", notnull=True, comment=tp_controller),
Field("host", "string", notnull=True, default='cdsweb.cern.ch', label='Store', comment=tp_host),
Field("collections", "string", comment=tp_collections),
Field("ratio", "double", notnull=True, default=1.0, comment=tp_ratio),
Field("id_categories", "reference categories", default=1, label='Category', comment=tp_category),
migrate="harvesters.table")
db.harvesters.controller.requires = \
IS_IN_SET(['articles', 'notes', 'preprints', 'proceedings', 'reports', 'talks', 'theses'])
# TEST THE DIFFERENT SYNTAX DEFINING FOREIGN KEY
db.harvesters.id_categories.requires = \
IS_IN_DB(db, 'categories.id', 'categories.code')
db.harvesters.id_projects.requires = \
IS_IN_DB(db, 'projects.project')
#db.harvesters.id_teams.requires = \
#IS_IN_DB(db, 'teams.id', 'teams.team')
db.harvesters.ratio.requires = \
IS_FLOAT_IN_RANGE(0., 1.0)
#-------------------------------------------------------------------------------
#
# STORE CONFIGURATiON
# FIELDS CONFIGURATiON
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
# FIELDS CONFIGURATiON
# FORM CONFIGURATiON
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
# FORM CONFIGURATiON
# GRID CONFIGURATiON
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
# GRID CONFIGURATiON
# STORE CONFIGURATiON
#
#-------------------------------------------------------------------------------
# -*- coding: utf-8 -*-
""" new_fields table and associated widgets
""" new_fields widgets
"""
#-------------------------------------------------------------------------------
#
# DEFINITION
#
#-------------------------------------------------------------------------------
db.define_table("new_fields",
Field("string", "string"),
Field("list_string", "list:string"),
Field("dictionary", "json"),
Field("python_code", "text"),
migrate="new_fields.table")
# NOTE: if we remove the json validator its seem to work ?
db.new_fields.dictionary.requires = None
#-------------------------------------------------------------------------------
#
# STORE CONFIGURATiON
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
# FIELDS CONFIGURATiON
......@@ -53,3 +31,9 @@ formModifier.configure(width=400)
# GRID CONFIGURATiON
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
# STORE CONFIGURATiON
#
#-------------------------------------------------------------------------------
# -*- coding: utf-8 -*-
""" projects table and associated widgets
""" projects widgets
"""
#-------------------------------------------------------------------------------
#
# DEFINITION
#
#-------------------------------------------------------------------------------
db.define_table("projects",
Field("project", "string", notnull=True, unique=True),
migrate="projects.table")
#-------------------------------------------------------------------------------
#
# STORE CONFIGURATiON
# FIELDS CONFIGURATiON
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
# FIELDS CONFIGURATiON
# FORM CONFIGURATiON
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
# FORM CONFIGURATiON
# GRID CONFIGURATiON
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
# GRID CONFIGURATiON
# STORE CONFIGURATiON
#
#-------------------------------------------------------------------------------
# -*- coding: utf-8 -*-
""" publications table and associated widgets
""" publications widgets
"""
#-------------------------------------------------------------------------------
#
# DEFINITION
#
#-------------------------------------------------------------------------------
tp_authors = \
"""List of authors separated by commma: J. Doe, P.-Y. Smith
For large collaboration the first author followed by et al.: J. Doe et al."""
tp_authors_cppm = \
"""List of authors separated by comma: P.-Y. Doe, J. Smith"""
tp_first = "first page"
tp_last = "last_page"
tp_report_numbers = \
"""List of report identifier separated by comma:
LHCb-PROC-2008-04, arXiv:0906.1516 """
tp_speaker = \
"""The name of the speaker: P.-Y. Smith"""
db.define_table("publications",
Field("title", "text", notnull=True),
Field("authors", "string", notnull=True, comment=tp_authors),
Field("id_collaborations", 'reference collaborations', default=undef_id, label="Collaboration"),
Field("id_publishers", 'reference publishers', default=undef_id, label="Publisher"),
Field("year", "integer", notnull=True, default=year, requires=IS_INT_IN_RANGE(1900, year+1)),
Field("doi", "string"),
Field("volume", "integer", requires=IS_EMPTY_OR(IS_INT_IN_RANGE(1, None))),
Field("first_page", "integer", requires=IS_EMPTY_OR(IS_INT_IN_RANGE(1, None)), comment=tp_first),
Field("last_page", "integer", requires=IS_EMPTY_OR(IS_INT_IN_RANGE(1, None)), comment=tp_last),
Field("e_print", "string", requires=IS_EMPTY_OR(IS_URL())),
Field("conference_title", "text", label='Title'),
Field("conference_url", "string", label='url', requires=IS_EMPTY_OR(IS_URL())),
Field("conference_start", "date", label='Start date'),
Field("conference_end", "date", label='End date'),
Field("conference_town", "string", label='Town'),
Field("id_countries", 'reference countries', default=undef_id, label='Country'),
Field("conference_speaker", "string", label='Speaker', comment=tp_speaker),
Field("report_numbers", "string", comment=tp_report_numbers),
Field("id_reports", 'reference reports', default=undef_id, label="Report type"),
Field("authors_cppm", "text", notnull=True, comment=tp_authors_cppm),
Field("id_teams", 'reference teams', default=undef_id, label='Team'),
Field("id_projects", 'reference projects', default=undef_id, label='Projects'),
Field("id_categories", 'reference categories', default=undef_id, label='AERES'),
migrate="publications.table")
db.publications.id_categories.requires = \
IS_IN_DB(db, 'categories.id', 'categories.code')
db.publications.id_collaborations.requires = \
IS_IN_DB(db, 'collaborations.id', 'collaborations.collaboration')
db.publications.id_countries.requires = \
IS_IN_DB(db, 'countries.id', 'countries.country')
db.publications.id_publishers.requires = \
IS_IN_DB(db, 'publishers.id', 'publishers.abbreviation')
db.publications.id_projects.requires = \
IS_IN_DB(db, 'projects.id', 'projects.project')
db.publications.id_reports.requires = \
IS_IN_DB(db, 'reports.id', 'reports.type')
db.publications.id_teams.requires = \
IS_IN_DB(db, 'teams.id', 'teams.team')
#-------------------------------------------------------------------------------
#
# STORE CONFIGURATiON
#
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
# FIELDS CONFIGURATiON
......@@ -217,4 +140,10 @@ gridModifier.append_filter(('authors_cppm', 'contains', T('select publications f
gridModifier.append_filter(('countries.country', 'contains', T('blab blab ....')))
gridModifier.configure_filters(plugins=['pFormToolTip'],
width=300)
\ No newline at end of file
width=300)
#-------------------------------------------------------------------------------
#
# STORE CONFIGURATiON
#
#-------------------------------------------------------------------------------
# -*- coding: utf-8 -*-
""" publishers table and associated widgets
""" publishers widgets