Commit 8f8ba09c authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Replace the preference reg_institute by inspirehep_institute_id.

parent c040b804
......@@ -34,7 +34,7 @@ def free_run():
All harvester parameters are defined via the selector.
"""
if not current.app.reg_institute:
if not current.app.inspirehep_institute_id:
return INLINE_ALERT % (T("Error"), MSG_NO_REG_INSTITUTE)
table = virtdb.free_harvester_selector
......@@ -93,7 +93,7 @@ def edit_insert():
no checks are run. The user is editing the record to fix problems.
"""
if not current.app.reg_institute:
if not current.app.inspirehep_institute_id:
return INLINE_ALERT % (T("Error"), MSG_NO_REG_INSTITUTE)
fields = ('controller',
......@@ -236,7 +236,7 @@ def insert_marcxml():
"""Insert a MarcXML record in the database.
"""
if not current.app.reg_institute:
if not current.app.inspirehep_institute_id:
return INLINE_ALERT % (T("Error"), MSG_NO_REG_INSTITUTE)
try:
......@@ -284,7 +284,7 @@ def run():
Search arguments are defined via the harvester selector.
"""
if not current.app.reg_institute:
if not current.app.inspirehep_institute_id:
return INLINE_ALERT % (T("Error"), MSG_NO_REG_INSTITUTE)
try:
......@@ -329,7 +329,7 @@ def run_all():
"""Run all harvesters in one go.
"""
if not current.app.reg_institute:
if not current.app.inspirehep_institute_id:
return INLINE_ALERT % (T("Error"), MSG_NO_REG_INSTITUTE)
collection_logs = []
......
......@@ -298,6 +298,7 @@
'install': 'installé',
'Institute': 'Institut',
'Institute number associated to CPPM authors': "Numéro de l'Institut associé aux auteurs du CPPM",
'Institute identifier in inspirehep.net.': "Identifiant du laboratoire dans inspirehep.net.",
'Invalid': 'Non conforme',
"Invalid database table '%s'": "Invalid database table '%s'",
'Invalid email': 'Invalid email',
......
......@@ -32,12 +32,12 @@ cfgPreferences = dict(dbtable='preferences',
'authorize_harvester_scan': False,
'authorize_user_login': False,
'harvester_start_year': year,
'reg_institute': None},
'inspirehep_institute_id': 0},
sourceConfig={
'authorize_harvester_scan': {'type': 'boolean'},
'authorize_user_login': {'type': 'boolean'},
'harvester_start_year': {'type': 'number'},
'reg_institute': {'type': 'string'}},
'inspirehep_institute_id': {'type': 'number'}},
width=250,
xtype='xpreferences')
......
......@@ -21,7 +21,6 @@ if db(db.preferences).count() != 3:
"It starts with the given value and "
"ends with the current year."))
if not db(db.preferences.property == "reg_institute").select():
db.preferences.insert(property="reg_institute",
definition=T("Regular expression defining the "
"name of our institute."))
if not db(db.preferences.property == "inspirehep_institute_id").select():
db.preferences.insert(property="inspirehep_institute_id",
definition=T("Institute identifier in inspirehep.net."))
# -*- coding: utf-8 -*-
""" NAME
fix-institute-id
SYNOPSIS
fix the institute identifier
DESCRIPTION
Up to version 0.8.13, the institute identifier is stored
in the preference reg_institute.
In the following version used the institute idenfier defined
in the inspirehep.net store.
This script remove the old property and create the new one.
OPTIONS
-h, --help
Display the help and exit.
EXAMPLE
> cd ...track_publications/scripts
> ./run fix-institute-id
AUTHOR
R. Le Gac -- Sep 2015
"""
if __name__ == "__main__":
import sys
from plugin_dbui import get_id
# the old property
rec_id = get_id(db.preferences, property="reg_institute")
if rec_id:
print "delete property reg_institute"
del db.preferences[rec_id]
# the new property
if not db(db.preferences.property == "inspirehep_institute_id").select():
rep = raw_input("inspirehep identifier: ")
if not rep:
print 'please enter a number'
sys.exit(1)
db.preferences.insert(property="inspirehep_institute_id",
value=int(rep),
definition=T("Institute identifier in inspirehep.net."))
# commit the change
rep = raw_input("Commit database changed [y/N]: ")
if rep == "y":
print "Database is modified"
db.commit()
# close
sys.exit(0)
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