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

Improved view for check and validate controller.

parent 877d1d1d
......@@ -4,69 +4,73 @@
import re
import plugin_dbui
MSG_NO_AUTHORS = "<br><br>Removing affiliation failed.<br>"\
"Use INSPIRES instead with the tool 'insert MARCXML'"
from gluon.storage import Storage
def check_validate():
"""Check and validate records.
"""
def append_msg(msgs, text, ref):
msg = [text]
msg.extend(ref)
msgs.append(msg)
msgs = []
logs = []
nfound = 0
nok = 0
nvalidated = 0
id_ok = db(db.status.code=='OK').select().first().id
# select rows according to user requirements
selector = plugin_dbui.Selector(virtdb.check_selector,
exclude_fields=('validate'))
rows = selector.select(db.publications, orderby=(db.projects.project,
db.categories.code))
rows = selector.select(db.publications,
orderby=(db.projects.project, db.categories.code))
# scan the publications
for row in rows:
li = []
# publication reference
ref = [row.publications.title,
row.projects.project,
row.categories.code,
row.publications.year]
nfound += 1
# skip publication already validated
if row.status.code == 'OK':
nok += 1
continue
# initialise the log for this record
msg = Storage()
logs.append(msg)
msg.category = row.categories.code
msg.id = row.publications.id
msg.title = row.publications.title
msg.year = row.publications.year
msg.txt = []
# publication to be checked
if row.status.code == '???':
text = T("Check record, the status is ???")
append_msg(li, text, ref)
msg.txt.append(text)
continue
# authors list
if 'et al' in row.publications.authors:
text = T("'et al.' in authors")
append_msg(li, text, ref)
msg.txt.append(text)
# submitted date
if not row.publications.submitted:
text = T("Submitted date is not defined")
append_msg(li, text, ref)
msg.txt.append(text)
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)
msg.txt.append(text)
# 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)
msg.txt.append(text)
# specific fields for article
if row.categories.usual == 'article':
......@@ -77,31 +81,36 @@ def check_validate():
if not row.publications.conference_speaker:
text = T("Conference speaker is missing")
append_msg(li, text, ref)
msg.txt.append(text)
# 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)
msg.txt.append(text)
# 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)
msg.txt.append(text)
# 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)
if not msg.txt:
nvalidated += 1
del logs[-1]
return dict(msgs=msgs)
if selector.validate:
# row.publications.update_record(id_status=id_ok)
pass
return dict(logs=logs,
nfound=nfound,
nok=nok,
nvalidated=nvalidated,
selector=selector)
def extract_authors():
......
......@@ -11,6 +11,7 @@
.my-li,
.my-ol {
margin-left: 35px;
margin-bottom: 0px;
}
.my-ol {
......@@ -24,6 +25,7 @@
.my-p-smallcap {
font-variant: small-caps;
margin-bottom: 1ex;
}
"""
......@@ -48,7 +50,7 @@
#
txt = harvester.controller.title()
response.write(myp_smallcap(txt))
#
# Scanning condition and results
#
......@@ -99,11 +101,9 @@
title = "%s. " % msg.title
if msg.url:
txt = [A("%s. " % title, _href=msg.url, _target="_blank")]
else:
txt = [title]
title = A(title, _href=msg.url, _target="_blank")
pass
action = msg.action
if action:
if action.startswith(T('Reject')):
......@@ -113,10 +113,10 @@
else:
colour = "grey"
pass
txt.append(SPAN(action, _style="color: %s;" % colour))
action = SPAN(action, _style="color: %s;" % colour)
pass
ol.append(LI(*txt))
ol.append(LI(title, action))
pass
response.write(ol)
......
{{
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()
my_style = """
.my-li,
.my-ol,
.my-p,
.my-p-smallcap {
font-family: Liberation Sherif, Sherif;
font-size: 11px;
}
.my-li,
.my-ol {
margin-left: 35px;
margin-bottom: 0px;
}
.my-ol {
list-style-type: decimal;
}
.my-p,
.my-p-smallcap {
margin-left: 20px;
}
.my-p-smallcap {
font-variant: small-caps;
margin-bottom: 1ex;
}
"""
response.write(BR())
response.write(STYLE(XML(my_style)))
def myli(txt):
txt = "&ndash; %s" % txt
return LI(XML(txt), _class="my-li")
def myol(*args):
return OL(*args, _class="my-ol")
def myp(txt):
return P(txt, _class="my-p")
def myp_smallcap(txt):
return P(txt, _class="my-p-smallcap")
#
# Header
#
response.write(myp_smallcap("Check and validate"))
#
# Scanning condition and results
#
ul = UL()
txt = T("Number of records found: %s") % nfound
ul.append(myli(txt))
txt = T("Number of records already validated: %s") % nok
ul.append(myli(txt))
txt = T("Number of invalid records: %s") % (nfound - nok - nvalidated)
ul.append(myli(txt))
response.write(ul)
#
# Log
#
response.write(BR())
response.write(myp_smallcap("Invalid records"))
ol = myol()
for msg in logs:
title = "%s, " % msg.title
txt = SPAN(', '.join(msg.txt), _style="color: red;")
id = SPAN(', id %s ' % msg.id, _style="color: green;")
ol.append(LI(title, txt, id))
pass
response.write(ol)
}}
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