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

Full implementation of the wizard check_validate.

parent bee6c550
""" Wizards Controllers
"""
import re
from plugin_dbui import Selector
from harvest_tools import get_id
def check_validate():
"""Check and validate records.
"""
selector = Selector(virtdb.check_selector, exclude_fields=('validate'))
rows = selector.select(db.publications, orderby=db.categories.code)
def append_msg(msgs, text, ref):
msg = [text]
msg.extend(ref)
msgs.append(msg)
msgs = []
print rows
# scan per category
# skip record with a status OK
# check field content - depend on the category
# validate the record
# select rows according to user requirements
selector = Selector(virtdb.check_selector, exclude_fields=('validate'))
rows = selector.select(db.publications, orderby=(db.projects.project,
db.categories.code))
return str(selector.as_dict())
\ No newline at end of file
# scan the publications
for row in rows:
li = []
# publication reference
ref = [row.publications.title,
row.projects.project,
row.categories.code,
row.publications.year]
# skip publication already validated
if row.status.code == 'OK':
continue
# publication to be checked
if row.status.code == '???':
text = T("Check record, the status is ???")
append_msg(li, text, ref)
continue
# authors list
if 'et al' in row.publications.authors:
text = T("'et al.' in authors")
append_msg(li, text, ref)
# submitted date
if not row.publications.submitted:
text = T("Submitted date is not defined")
append_msg(li, text, ref)
if not re.match('^\d{4}(-\d{2})?(-\d{2})?$', row.publications.submitted):
text = T("Submitted date is not valid")
append_msg(li, text, ref)
# check latex syntax
title = row.publications.title
if ("^" in title and not "$") or "√" in title:
text = T("Check latex syntax")
append_msg(li, text, ref)
# specific fields for article
if row.categories.usual == 'article':
pass
# specific fields for proceeding
elif row.categories.usual == 'proceeding':
if not row.publications.conference_speaker:
text = T("Conference speaker is missing")
append_msg(li, text, ref)
# specific fields for talk
elif row.categories.usual == 'report':
if not row.publications.report_numbers:
text = T("Report number is missing")
append_msg(li, text, ref)
# specific fields for report
elif row.categories.usual == 'talk':
if not row.publications.conference_speaker:
text = T("Conference speaker is missing")
append_msg(li, text, ref)
msgs.extend(li)
# update publication status
if not li and selector.validate:
id_ok = db(db.status.code=='OK').select().first().id
# row.publications.update_record(id_status=id_ok)
return dict(msgs=msgs)
\ No newline at end of file
......@@ -3,6 +3,7 @@
'"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN': '"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN',
'%Y-%m-%d': '%Y-%m-%d',
'%Y-%m-%d %H:%M:%S': '%Y-%m-%d %H:%M:%S',
"'et al.' in authors": "'et al.' dans les authors",
'Abbreviation': 'Abréviation',
'ACL': 'ACL',
'ACLN': 'ACLN',
......@@ -55,6 +56,7 @@
'Change password': 'Change password',
'Chapter(s)': 'Chaptitre(s)',
'check and validate': 'vérifier et valider',
'Check latex syntax': 'Vérifier la syntaxe latex',
'Check to delete': 'Check to delete',
'Click on the link http://localhost:8000/track_publications/default/user/reset_password/%(key)s to reset your password': 'Click on the link http://localhost:8000/track_publications/default/user/reset_password/%(key)s to reset your password',
'Client IP': 'Client IP',
......@@ -67,6 +69,7 @@
'COM': 'COM',
'Conditions': 'Conditions',
'Conference': 'Conférence',
'Conference speaker is missing': "L'orateur n'est pas défini",
'Configuration': 'Configuration',
'Controller': 'Controller',
'Converters': 'Convertisseurs',
......@@ -244,6 +247,7 @@
'Renew': 'Renew',
'Report': 'Rapport',
'Report identifier separated by comma: LHCb-PROC-2008-04': 'Numéro(s) du rapport séparé par des virgules : LHCb-PROC-2008-04',
'Report number is missing': "Le numéro du rapport n'est pas défini",
'reports': 'rapports',
'Reports': 'Rapports',
'Request reset password': 'Request reset password',
......
{{
response.write(HR())
for msg in msgs:
= SPAN(msg[0].upper(), _style="color:red")
for i in range(1,len(msg)):
= BR()
= msg[i]
pass
= HR()
pass
}}
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