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

Add the regex rule REG_SUBMITTED.

parent 641c0d9c
......@@ -15,7 +15,7 @@ from callbacks import (INHIBIT_CASCADE_DELETE,
from datetime import datetime
from gluon.tools import PluginManager
from regex import REG_COLLABORATION
from regex import REG_COLLABORATION, REG_SUBMITTED
#-------------------------------------------------------------------------------
#
......
......@@ -122,6 +122,6 @@ db.publications.origin.requires = IS_EMPTY_OR(IS_URL())
db.publications.publication_url.requires = IS_EMPTY_OR(IS_URL())
# rule: 2012-12 or 2012-12-31
db.publications.submitted.requires = IS_MATCH('\d{4}-\d{2}(-\d{2})?')
db.publications.submitted.requires = IS_MATCH(REG_SUBMITTED)
db.publications.year.requires = IS_INT_IN_RANGE(1900, year+1)
\ No newline at end of file
......@@ -5,6 +5,7 @@
"""
import re
import regex
from gluon import current
from plugin_dbui import (UNDEF,
......@@ -13,8 +14,8 @@ from plugin_dbui import (UNDEF,
get_where_query)
# syntax for the submission date YYYY or YYYY-MM or YYYY-MM-DD
REG_SUBMITTED = re.compile('^\d{4}(-\d{2})?(-\d{2})?$')
# syntax for the submission date YYYY-MM or YYYY-MM-DD
REG_SUBMITTED = re.compile(regex.REG_SUBMITTED)
# HTML code like >
REG_HTML = re.compile('&[a-z]+;')
......
......@@ -95,7 +95,7 @@ REG_IDS_OK = re.compile("^\[[\d, ]*\]$")
REG_INT = re.compile("^\d+$")
REG_OAI = re.compile('oai:([a-z\.]+):([\d]+)')
REG_SUBMITTED = re.compile("\d{4}-\d{2}")
REG_SUBMITTED = re.compile(regex.REG_SUBMITTED)
REG_VOLUME = re.compile('[A-Z]+ *(\d.*)')
REG_YEAR = re.compile("(\d{4})")
......
......@@ -13,4 +13,9 @@ on field contents.
# - CTA Consortium
# - any mixture of the above separated by a comma
#
REG_COLLABORATION = r'^[A-Za-z0-9\-/, ]+([Cc]ollaboration|[Cc]onsortium|[Gg]roup)[s]?$'
\ No newline at end of file
REG_COLLABORATION = r'^[A-Za-z0-9\-/, ]+([Cc]ollaboration|[Cc]onsortium|[Gg]roup)[s]?$'
# submitted field
# - 2012-12
# - 2012-12-31
REG_SUBMITTED = r'\d{4}-\d{2}(-\d{2})?'
\ No newline at end of file
......@@ -46,6 +46,7 @@ if __name__ == "__main__":
import datetime
import re
import regex
import sys
from argparse import ArgumentParser, FileType
......@@ -55,7 +56,7 @@ if __name__ == "__main__":
REG_CONF_2 = re.compile('(\d+) (\w{3}) - \d+ \w+ (\d{4})')
REG_DEFENSE = re.compile('\w* *(\d{2}) (\w{3}) (\d{4})')
REG_DD_MM_YYYY = re.compile('(\d{2}) *(\d{2}) *(\d{4})')
REG_SUBMITTED = re.compile('^\d{4}-\d{2}(-\d{2})?$')
REG_SUBMITTED = re.compile(regex.REG_SUBMITTED)
YY = str(datetime.date.today().year - 2000)
......
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