Commit 6e99f87a authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Implement affiliation rules in CheckAndFix. Remove preferences:...

Implement affiliation rules in CheckAndFix. Remove preferences: inspihep_institure_id, add_rules_reg_institute.
parent 2347513d
......@@ -26,7 +26,7 @@ from plugin_dbui import (get_id,
UNDEF_ID)
MODE_DRY_RUN = T(DRY_RUN)
MSG_NO_REG_INSTITUTE = "Preference REG_INSTITUTE is not defined."
MSG_NO_AFFILIATION = "Affiliation keys are not defined !!!"
MSG_NO_HARVESTER = "No harvesters for your selection !!!"
MSG_NO_RECORD = "Sorry, the record does not exist."
......@@ -35,8 +35,8 @@ def free_run():
All harvester parameters are defined via the selector.
"""
if not current.app.inspirehep_institute_id:
return inline_alert(T("Error"), T(MSG_NO_REG_INSTITUTE))
if db(db.affiliation_keys.id > 0).count() == 0:
return inline_alert(T("Error"), T(MSG_NO_AFFILIATION))
table = virtdb.free_harvester_selector
fields = ('collections',
......@@ -95,8 +95,8 @@ def edit_insert():
no checks are run. The user is editing the record to fix problems.
"""
if not current.app.inspirehep_institute_id:
return inline_alert(T("Error"), T(MSG_NO_REG_INSTITUTE))
if db(db.affiliation_keys.id > 0).count() == 0:
return inline_alert(T("Error"), T(MSG_NO_AFFILIATION))
fields = ('controller',
'host',
......@@ -285,8 +285,8 @@ def insert_marcxml():
"""Insert a MarcXML record in the database.
"""
if not current.app.inspirehep_institute_id:
return inline_alert(T("Error"), T(MSG_NO_REG_INSTITUTE))
if db(db.affiliation_keys.id > 0).count() == 0:
return inline_alert(T("Error"), T(MSG_NO_AFFILIATION))
try:
selector = Selector(virtdb.marc12_selector, exclude_fields=('mode'))
......@@ -333,8 +333,8 @@ def run():
Search arguments are defined via the harvester selector.
"""
if not current.app.inspirehep_institute_id:
return inline_alert(T("Error"), T(MSG_NO_REG_INSTITUTE))
if db(db.affiliation_keys.id > 0).count() == 0:
return inline_alert(T("Error"), T(MSG_NO_AFFILIATION))
try:
selector = Selector(virtdb.harvester_selector,
......@@ -387,8 +387,8 @@ def run_all():
"""Run all harvesters in one go.
"""
if not current.app.inspirehep_institute_id:
return inline_alert(T("Error"), T(MSG_NO_REG_INSTITUTE))
if db(db.affiliation_keys.id > 0).count() == 0:
return inline_alert(T("Error"), T(MSG_NO_AFFILIATION))
collection_logs = []
logs = []
......
......@@ -10,6 +10,7 @@
'• title, conference title, date and town': '– titre ainsi que le titre, la ville et la date de la conférence',
'• title, publisher, volume and pages': '– titre, revue, volume et pages',
"'et al.' in authors": "'et al.' dans les authors",
"'RecordConf' object has no attribute 'country'": "'RecordConf' object has no attribute 'country'",
'A report already exists with the same title': 'Un rapport existe deja avec le même titre',
'A talk/proceeding already exists with the same:': 'Un acte ou une présentation existe déja avec le même:',
'Abbreviation': 'Abréviation',
......@@ -26,6 +27,7 @@
'administrators, librairians,...': 'administrateurs, documentalistes,...',
'Affiliation': 'Affiliation',
'affiliation keys': "clés définissant l'affiliation",
'Affiliation keys are not defined !!!': "Les clés définissant votre affiliation n'existe pas !!!",
'affiliation_keys': "clés définissant l'affiliation",
'affiliation_rules': 'affiliation_rules',
'Agencies': 'Agences',
......@@ -45,7 +47,6 @@
'Articles published': 'Articles publiés',
'ASCL': 'ASCL',
'Associate a title to each section. Rule: section1: title1, secton2: title2,....': 'Associate a title to each section. Rule: section1: title1, secton2: title2,....',
'Author not found!': "L'auteur n'a pas été trouvé !",
'auth_cas': 'auth_cas',
'auth_event': 'auth_event',
'auth_group': 'auth_group',
......@@ -53,6 +54,7 @@
'auth_permission': 'auth_permission',
'auth_user': 'auth_user',
'Author': 'Auteur',
'Author not found!': "L'auteur n'a pas été trouvé !",
"author's rescue list": 'liste de secours pour les auteurs du laboratoire',
'Authorize automatic scan.': 'Authorise le mossonage automatique.',
'Authors': 'Auteurs',
......@@ -325,9 +327,9 @@
'ISBN': 'ISBN',
'ISSN': 'ISSN',
'Javascript API': 'Javascript API',
'Keys already exist!': 'La clé existe!',
'Key U': 'Clé U',
'Key V': 'Clé V',
'Keys already exist!': 'La clé existe!',
'Last name': 'Last name',
'Level': 'Niveau',
'Level 1': 'Niveau 1',
......@@ -472,9 +474,9 @@
'Property': 'Propriété',
'Publication': 'Publication',
'Publication category associated to the found records.': 'Catégorie associée aux enregistrements.',
'Publication not found!': "La publication n'a pas été trouvé !",
'publications': 'publications',
'Publications': 'Publications',
'Publication not found!': "La publication n'a pas été trouvé !",
'Publisher': 'Revue',
'publisher': 'revue',
'Publishers': 'Revues',
......@@ -593,7 +595,7 @@
'Serie': 'Serie',
'Serie Axis': 'Serie Axis',
'Serie Granularity': 'Serie Granularity',
'Server is not reachable or respond badly!': "Le serveur est injoignable ou répond mal !",
'Server is not reachable or respond badly!': 'Le serveur est injoignable ou répond mal !',
'Service': 'Service',
'Several publications refer to it.': 'Several publications refer to it.',
'Sign Up': 'Sign Up',
......
......@@ -31,13 +31,11 @@ cfgPreferences = dict(dbtable='preferences',
source={
'authorize_harvester_scan': False,
'authorize_user_login': False,
'harvester_start_year': year,
'inspirehep_institute_id': 0},
'harvester_start_year': year},
sourceConfig={
'authorize_harvester_scan': {'type': 'boolean'},
'authorize_user_login': {'type': 'boolean'},
'harvester_start_year': {'type': 'number'},
'inspirehep_institute_id': {'type': 'number'}},
'harvester_start_year': {'type': 'number'}},
width=250,
xtype='xpreferences')
......
......@@ -4,12 +4,6 @@
"""
if db(db.preferences).count() != 3:
if not db(db.preferences.property == "add_rules_reg_institute").select():
db.preferences.insert(property='add_rules_reg_institute',
definition=T("For expert. "
"Add rules to the regular expression"
" defining my institute."))
if not db(db.preferences.property == "authorize_harvester_scan").select():
db.preferences.insert(property='authorize_harvester_scan',
definition=T("Harvesters are ran automatically "
......@@ -26,7 +20,3 @@ if db(db.preferences).count() != 3:
"the harvesters can be ran. "
"It starts with the given value and "
"ends with the current year."))
if not db(db.preferences.property == "inspirehep_institute_id").select():
db.preferences.insert(property="inspirehep_institute_id",
definition=T("Institute identifier in inspirehep.net."))
......@@ -102,28 +102,23 @@ class CheckAndFix(object):
"""
# alias
db = self.db
app = current.app
reg_institute = app.reg_institute
# regular expression for the institute is not defined
# find it using the institute definition in inspirehep
# store the regular expression in current.app for a later use
# regular expression for the affiliation is not defined
# build it using the affiliation keys.
if not reg_institute:
institute_id = app.inspirehep_institute_id
institute = load_record("inspirehep.net", institute_id)
reg_institute = institute.rex()
reg_institute = None
for row in db(db.affiliation_keys.id > 0).iterselect():
# additional rules for the regular expression
add_rules = app.add_rules_reg_institute
if add_rules:
if add_rules.startswith('|'):
reg_institute = "%s%s" % (reg_institute, add_rules)
else:
reg_institute = "%s|%s" % (reg_institute, add_rules)
reg = "^%(key_u)s%(key_v)s" % row
app.institute = institute
app.reg_institute = reg_institute
if reg_institute is None:
reg_institute = reg
else:
reg_institute = "%s|%s" % (reg_institute, reg)
return reg_institute
......@@ -588,8 +583,12 @@ class CheckAndFix(object):
if not isinstance(record, RecordThesis):
return
db = self.db
is_cppm = db(db.affiliation_keys.key_u.contains("CPPM")).count() > 0
# CPPM: fix the name of Aix-Marseille university
if current.app.inspirehep_institute_id == 902989:
if is_cppm:
year = REG_YEAR.search(record.these_defense()).group(1)
if int(year) < 2012:
......
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