Commit 850080bd authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add the rules REG_CONF_DATES and REG_DEFENSE

parent f772ae6a
......@@ -15,7 +15,10 @@ from callbacks import (INHIBIT_CASCADE_DELETE,
from datetime import datetime
from gluon.tools import PluginManager
from regex import REG_COLLABORATION, REG_SUBMITTED
from regex import (REG_COLLABORATION,
REG_CONF_DATES,
REG_DEFENSE,
REG_SUBMITTED)
#-------------------------------------------------------------------------------
#
......
......@@ -109,13 +109,11 @@ db.publications.title.filter_in = dbui.CLEAN_SPACES
db.publications.authors.requires = IS_LENGTH(65535)
# rule: 30 Dec 2012
db.publications.defense.requires = IS_MATCH('\d{2} [A-Z][a-z]{2} \d{4}')
db.publications.defense.requires = IS_MATCH(REG_DEFENSE)
db.publications.id_publishers.requires = IS_IN_DB(db, 'publishers.abbreviation')
# rule: 10-14 Dec 2012 or 28 Jun - 4 Jul 2012
reg1 = '\d{1,2}-\d{1,2} [A-Z][a-z]{2} \d{4}'
reg2 = '\d{1,2} [A-Z][a-z]{2} -\d{1,2} [A-Z][a-z]{2} \d{4}'
db.publications.conference_dates.requires = IS_MATCH('%s|%s' % (reg1, reg2))
db.publications.conference_dates.requires = IS_MATCH(REG_CONF_DATES)
db.publications.conference_url.requires = IS_EMPTY_OR(IS_URL())
db.publications.origin.requires = IS_EMPTY_OR(IS_URL())
......
# *-* coding: utf-8 *-*
""" A collections of regular expression used to applied rules
""" A collections of regular expression defining rules to be applied
on field contents.
@author: R. Le Gac
......@@ -15,7 +15,21 @@ on field contents.
#
REG_COLLABORATION = r'^[A-Za-z0-9\-/, ]+([Cc]ollaboration|[Cc]onsortium|[Gg]roup)[s]?$'
# submitted field
# Conference dates
# - 10-14 Dec 2012
# - 28 Jun - 4 Jul 2012
#
reg1 = r'\d{1,2}-\d{1,2} [A-Z][a-z]{2} \d{4}'
reg2 = r'\d{1,2} [A-Z][a-z]{2} -\d{1,2} [A-Z][a-z]{2} \d{4}'
REG_CONF_DATES = r'%s|%s' % (reg1, reg2)
# Defence date
# - 30 Dec 2012
#
REG_DEFENSE = r'\d{2} [A-Z][a-z]{2} \d{4}'
# Submitted field
# - 2012-12
# - 2012-12-31
#
REG_SUBMITTED = r'\d{4}-\d{2}(-\d{2})?'
\ No newline at end of file
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