Commit 43da484b authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Replace the constant INLINE_ALERT by the function inline_alert.

parent 9515727f
......@@ -20,7 +20,7 @@ from invenio_tools import (load_record,
RecordThesis,
REG_INT)
from plugin_dbui import (get_id,
INLINE_ALERT,
inline_alert,
Selector,
to_formPanel,
UNDEF_ID)
......@@ -36,7 +36,7 @@ def free_run():
"""
if not current.app.inspirehep_institute_id:
return INLINE_ALERT % (T("Error"), T(MSG_NO_REG_INSTITUTE))
return inline_alert(T("Error"), T(MSG_NO_REG_INSTITUTE))
table = virtdb.free_harvester_selector
fields = ('collections',
......@@ -56,7 +56,7 @@ def free_run():
msg = T('All fields of the form have to be defined !!!')
msg += "<br>"
msg += T('The field "%s" is missing ...') % T(table[el].label)
return INLINE_ALERT % (T('Error'), msg)
return inline_alert(T('Error'), msg)
tool = build_harvester_tool(db,
selector.id_teams,
......@@ -68,7 +68,7 @@ def free_run():
dry_run=(selector.mode == MODE_DRY_RUN),
debug=False)
if not tool:
return INLINE_ALERT % (T('Error'), T('Select an harvester.'))
return inline_alert(T('Error'), T('Select an harvester.'))
tool.process_url(selector.host, selector.collections)
......@@ -96,7 +96,7 @@ def edit_insert():
"""
if not current.app.inspirehep_institute_id:
return INLINE_ALERT % (T("Error"), T(MSG_NO_REG_INSTITUTE))
return inline_alert(T("Error"), T(MSG_NO_REG_INSTITUTE))
fields = ('controller',
'host',
......@@ -118,7 +118,7 @@ def edit_insert():
msg = T("The <i>record id</i> is not well formed.")
msg += "<br>"
msg += T("Use only digit character, no comma, no dot...")
return INLINE_ALERT % (T('Error'), msg)
return inline_alert(T('Error'), msg)
selector = Selector(table)
......@@ -127,17 +127,13 @@ def edit_insert():
msg = T('All fields of the form have to be defined !!!')
msg += "<br>"
msg += T('The field "%s" is missing ...') % T(table[el].label)
return INLINE_ALERT % (T('Error'), msg)
return inline_alert(T('Error'), msg)
# record
record = load_record(selector.host, selector.record_id)
if record is None:
# NOTE
# Bug in plugin dbui 0.7.1 in INLINE_ALERT
msg = '<script>Ext.Msg.alert("%s", "%s");</script>'
msg = msg % (T('Error'), T(MSG_NO_RECORD))
return msg
return inline_alert(T('Error'), T(MSG_NO_RECORD))
# form configuration
cfg = to_formPanel(db.publications)
......@@ -283,7 +279,7 @@ def insert_marcxml():
"""
if not current.app.inspirehep_institute_id:
return INLINE_ALERT % (T("Error"), T(MSG_NO_REG_INSTITUTE))
return inline_alert(T("Error"), T(MSG_NO_REG_INSTITUTE))
try:
selector = Selector(virtdb.marc12_selector, exclude_fields=('mode'))
......@@ -298,7 +294,7 @@ def insert_marcxml():
dry_run=(selector.mode == MODE_DRY_RUN),
debug=False)
if not tool:
return INLINE_ALERT % (T('Error'), T('Select an harvester.'))
return inline_alert(T('Error'), T('Select an harvester.'))
tool.process_xml(selector.xml)
......@@ -331,7 +327,7 @@ def run():
"""
if not current.app.inspirehep_institute_id:
return INLINE_ALERT % (T("Error"), T(MSG_NO_REG_INSTITUTE))
return inline_alert(T("Error"), T(MSG_NO_REG_INSTITUTE))
try:
selector = Selector(virtdb.harvester_selector,
......@@ -356,7 +352,7 @@ def run():
dry_run=(selector.mode == MODE_DRY_RUN),
debug=False)
if not tool:
return INLINE_ALERT % (T('Error'), T('Select an harvester.'))
return inline_alert(T('Error'), T('Select an harvester.'))
tool.process_url(row.harvesters.host, row.harvesters.collections)
......@@ -385,7 +381,7 @@ def run_all():
"""
if not current.app.inspirehep_institute_id:
return INLINE_ALERT % (T("Error"), T(MSG_NO_REG_INSTITUTE))
return inline_alert(T("Error"), T(MSG_NO_REG_INSTITUTE))
collection_logs = []
logs = []
......@@ -405,7 +401,7 @@ def run_all():
harvesters = db(query).select(db.harvesters.ALL)
if not len(harvesters):
return INLINE_ALERT % (T('Error'), T(MSG_NO_HARVESTER))
return inline_alert(T('Error'), T(MSG_NO_HARVESTER))
for harvester in harvesters:
......@@ -419,7 +415,7 @@ def run_all():
dry_run=(selector.mode == MODE_DRY_RUN),
debug=False)
if not tool:
return INLINE_ALERT % (T('Error'), T('Select an harvester.'))
return inline_alert(T('Error'), T('Select an harvester.'))
tool.process_url(harvester.host, harvester.collections)
......
......@@ -5,12 +5,10 @@ import json
import re
from gluon.dal import smart_query
from plugin_dbui import Selector
from plugin_dbui import inline_alert, Selector
from reporting_tools import get_converter, repr_team_project
INLINE_ALERT = "<script>Ext.Msg.alert('%s', '%s');</script>"
MSG_NO_METRIC = T("Please select a metric....")
MSG_NO_TABLE = T("Invalid database table '%s'")
MSG_NO_METRIC = "Please select a metric...."
def index():
......@@ -27,7 +25,7 @@ def index():
# protection
if not selector.id_metrics:
return INLINE_ALERT % (T("Error"), MSG_NO_METRIC)
return inline_alert(T("Error"), T(MSG_NO_METRIC))
# retrieve metric data
metric = db.metrics[selector.id_metrics]
......
......@@ -9,6 +9,7 @@ from check_tools import check_publication
from gluon.storage import Storage
from harvest_tools import DRY_RUN
from plugin_dbui import (CALLBACK_ERRORS,
inline_alert,
is_foreign_field,
get_foreign_field,
get_id,
......@@ -17,11 +18,8 @@ from plugin_dbui import (CALLBACK_ERRORS,
MODE_DRY_RUN = T(DRY_RUN)
INLINE_ALERT = "<script>Ext.Msg.alert('%s', '%s');</script>"
MSG_NO_AUTHORS = "<br><br>Removing affiliation failed.<br>"\
"Use INSPIRES instead with the tool 'insert MARCXML'"
"Use INSPIRES instead with the tool 'insert MARCXML'"
def check_validate():
......@@ -91,7 +89,7 @@ def compare_publications():
data, idrow = [], []
if 'id1' not in request.vars or 'id2' not in request.vars:
return INLINE_ALERT % (T('Error'), T('Specify id1 and id2 in the URL'))
return inline_alert(T('Error'), T('Specify id1 and id2 in the URL'))
row1 = db.publications[request.vars.id1]
row2 = db.publications[request.vars.id2]
......
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