diff --git a/hal/create_xml2hal.py b/hal/create_xml2hal.py index 3d9a4236d2bb3fb813053c691bd4bb9a9a74626a..44e436f16bfb5c7ddcaf5487910d016866820a24 100644 --- a/hal/create_xml2hal.py +++ b/hal/create_xml2hal.py @@ -19,7 +19,7 @@ import html ############################################################################################################################# ############################################################################################################################# -def createXml_sendHal(numero,listauthors, lang_title, title_publi, name_conf, nb_pages, date_pub, listdomains, type_pub, ville, pays, pays_acr, doi_value, editor_book, volume, pubmed, name_user, labo_auth_final, id_hal_user, login_user, login_depot, passwd_depot, bool_depot_preprod, bool_depot_prod): +def createXml_sendHal(numero,listauthors, lang_title, title_publi, name_conf, nb_pages, date_pub, listdomains, type_pub, ville, pays, pays_acr, doi_value, editor_book, volume, pubmed, firstname_user, name_user, labo_auth_final, id_hal_user, login_user, login_depot, passwd_depot, bool_depot_preprod, bool_depot_prod): print ("method createXml_sendHal begin") ## VARIABLES CREATION XML errormsg="" @@ -56,11 +56,17 @@ def createXml_sendHal(numero,listauthors, lang_title, title_publi, name_conf, nb for auth_all in listauthors : auth_all = auth_all.strip() print("auth_all {0}".format(auth_all)) - auth = auth_all.split(' ') - if len(auth) != 2 : - errormsg+="Erreur probable sur le nom {0}, ".format(auth_all) - nom_auth = auth[0] - prenom_auth = auth[-1] + + if (firstname_user in auth_all) and (name_user in auth_all) : + auth = auth_all.split(' ') + prenom_auth = firstname_user + nom_auth = name_user + else : + auth = auth_all.split(' ') + if len(auth) != 2 : + errormsg+="Erreur probable sur le nom {0}, ".format(auth_all) + prenom_auth = auth[0] + nom_auth = auth[-1] print("nom_auth {0} prenom_auth {1}".format(nom_auth, prenom_auth)) author = etree.SubElement(titleStmt, "author") author.set("role","aut") @@ -103,11 +109,24 @@ def createXml_sendHal(numero,listauthors, lang_title, title_publi, name_conf, nb for auth_all in listauthors : auth_all = auth_all.strip() - auth = auth_all.split(' ') - nom_auth = auth[0].strip() - nom_auth = nom_auth - prenom_auth = auth[1].strip() - prenom_auth = prenom_auth + + + if (firstname_user in auth_all) and (name_user in auth_all) : + auth = auth_all.split(' ') + prenom_auth = firstname_user + nom_auth = name_user + else : + auth = auth_all.split(' ') + if len(auth) != 2 : + errormsg+="Erreur probable sur le nom {0}, ".format(auth_all) + prenom_auth = auth[0] + nom_auth = auth[-1] + + #auth = auth_all.split(' ') + #nom_auth = auth[0].strip() + #nom_auth = nom_auth + #prenom_auth = auth[1].strip() + #prenom_auth = prenom_auth author = etree.SubElement(analytic, "author") author.set("role","aut") persName = etree.SubElement(author, "persName") @@ -299,7 +318,7 @@ def createXml_sendHal(numero,listauthors, lang_title, title_publi, name_conf, nb #################################################################### @shared_task -def sendselect_2hal(name_user, login_user,id_hal_user,mail_reponse,labo_auth_final,listdomains,login_depot,passwd_depot,choice_depot,list_publis_to_update,csvfile): +def sendselect_2hal(firstname_user, name_user, login_user,id_hal_user,mail_reponse,labo_auth_final,listdomains,login_depot,passwd_depot,choice_depot,list_publis_to_update,csvfile): print("list_publis_to_update") print(list_publis_to_update) mail_message = "Bonjour\n\nSuite à votre demande sur l'appli Haltools, veuillez trouver ci-dessous les résultats de dépôts.\n\n" @@ -338,8 +357,9 @@ def sendselect_2hal(name_user, login_user,id_hal_user,mail_reponse,labo_auth_fin if numero in list_publis_to_update : # ie publi selected # encodage + rep = (600,'Erreur lors de la creation du XML') print("createXml_sendHal pour {0}".format(numero)) - rep = createXml_sendHal(numero,listauthors, lang_title, title_publi, name_conf, nb_pages, date_pub, listdomains, type_pub, ville, pays, pays_acr, doi_value, editor_book, volume, pubmed, name_user, labo_auth_final, id_hal_user, login_user, login_depot, passwd_depot, bool_depot_preprod, bool_depot_prod) + rep = createXml_sendHal(numero,listauthors, lang_title, title_publi, name_conf, nb_pages, date_pub, listdomains, type_pub, ville, pays, pays_acr, doi_value, editor_book, volume, pubmed, firstname_user, name_user, labo_auth_final, id_hal_user, login_user, login_depot, passwd_depot, bool_depot_preprod, bool_depot_prod) print("Resultat pour {0} -> code : {1} - requ msg : {2}".format(numero,rep[0],rep[1])) if (int(rep[0]) == 200) or (int(rep[0]) == 202) : mail_message+="La publi au numéro {0} et au titre {1} publiée en {2} a bien été déposée {3}\n".format(numero, title_publi, date_pub, mailchoicedepot) diff --git a/hal/dict_countries.py b/hal/dict_countries.py index 33348761439310caa5157aa8693d353c71448d5b..07b5063dd25b26ced2b76c05fd609ab3c45b3d1c 100644 --- a/hal/dict_countries.py +++ b/hal/dict_countries.py @@ -153,6 +153,7 @@ dict_countries = { "TAJIKISTAN":"TJ", "TANZANIA":"TZ", "THAILAND":"TH", + "THE NETHERLANDS":"NL", "TOGO":"TG", "TUNISIA":"TN", "TURKEY":"TR", diff --git a/hal/forms.py b/hal/forms.py index 08c7ade814e2d4fc97cdd0a55012ef809f1b70e9..8bca3c2ee397575fa79d9e125ccd26a6813e9e74 100644 --- a/hal/forms.py +++ b/hal/forms.py @@ -114,6 +114,7 @@ class Bibtex2halForm(forms.Form): class Bibformat2halForm(forms.Form): name_user = forms.CharField(required=True, max_length=40, label="Nom chercheur (*)") + firstname_user = forms.CharField(required=True, max_length=40, label="Prenom chercheur (*)") id_hal_user = forms.CharField(required=True, max_length=40, label="IdHal chercheur (*)") login_user = forms.CharField(required=True, max_length=40, label="Login HAL chercheur (*)") #choice_source = forms.ChoiceField(widget=forms.RadioSelect, choices=CHOICES_SOURCE_BIBTEX, label="Choix de la source", initial='DBLP' ) diff --git a/hal/management/commands/send_test_tei.py b/hal/management/commands/send_test_tei.py index 2e660eedb8d62a4ef647a3d2b78079dd831ee161..ce02e4878351c3813c8218a3672bf7173e72475e 100644 --- a/hal/management/commands/send_test_tei.py +++ b/hal/management/commands/send_test_tei.py @@ -13,7 +13,7 @@ class Command(BaseCommand): login_user = 'bdoreau' id_hal_user = 'bastien-doreau' login_depot = 'bdoreau' - passwd_depot = '******' + passwd_depot = 'mbrv1232' namefile = BASE_DIR+"/xml_files/bdoreauCI1.xml" diff --git a/hal/templates/hal/bibformat_2hal.html b/hal/templates/hal/bibformat_2hal.html index ed18e4661656862bddb38e1f82bf094c080cb0f5..246a3fb2381ac8d5f0bd2ce06d6cb2d88478005c 100644 --- a/hal/templates/hal/bibformat_2hal.html +++ b/hal/templates/hal/bibformat_2hal.html @@ -106,7 +106,15 @@ {{ form.name_user }} </div> </div> - + + <div class="col-lg-3"> + <div class="fieldWrapper"> + {{ form.firstname_user.errors }} + {{ form.firstname_user.label_tag }}<br/> + {{ form.firstname_user }} + </div> + </div> + <div class="col-lg-3"> <div class="fieldWrapper"> {{ form.id_hal_user.errors }} @@ -114,14 +122,25 @@ {{ form.id_hal_user }} </div> </div> - + <div class="col-lg-3"> <div class="fieldWrapper"> - {{ form.mail_reponse.errors }} - {{ form.mail_reponse.label_tag }}<br/> - {{ form.mail_reponse }} - </div> + {{ form.login_user.errors }} + {{ form.login_user.label_tag }}<br/> + {{ form.login_user }} + </div> </div> + + <!-- 2e ligne --> + + <div class="col-lg-3"> + <div class="fieldWrapper"> + {{ form.mail_reponse.errors }} + {{ form.mail_reponse.label_tag }}<br/> + {{ form.mail_reponse }} + </div> + </div> + <div class="col-lg-3"> <div class="fieldWrapper"> {{ form.labo_auth_final.errors }} @@ -130,16 +149,8 @@ </div> </div> - <!-- 2e ligne --> - <div class="col-lg-3"> - <div class="fieldWrapper"> - {{ form.login_user.errors }} - {{ form.login_user.label_tag }}<br/> - {{ form.login_user }} - </div> - </div> - <div class="col-lg-3"> + <div class="col-lg-2"> <div class="fieldWrapper"> {{ form.login_depot.errors }} {{ form.login_depot.label_tag }}<br/> @@ -147,15 +158,15 @@ </div> </div> - <div class="col-lg-3"> + <div class="col-lg-2"> <div class="fieldWrapper"> {{ form.passwd_depot.errors }} {{ form.passwd_depot.label_tag }}<br/> {{ form.passwd_depot }} </div> </div> - - <div class="col-lg-3"> + + <div class="col-lg-2"> <div class="fieldWrapper"> {{ form.choice_depot.errors }} {{ form.choice_depot.label_tag }}<br/> diff --git a/hal/views.py b/hal/views.py index abfa21b5fa9b19060ec579ae5026804aa54fc538..b492cbfe1770ae2fc0de69087876af7ee854dd65 100644 --- a/hal/views.py +++ b/hal/views.py @@ -181,6 +181,7 @@ def bibformat_2hal(request, csvfile): if form.is_valid(): print("method views.bibformat_2hal FORM VALID") name_user = form.cleaned_data['name_user'] + firstname_user = form.cleaned_data['firstname_user'] login_user = form.cleaned_data['login_user'] id_hal_user = form.cleaned_data['id_hal_user'] mail_reponse = form.cleaned_data['mail_reponse'] @@ -201,7 +202,7 @@ def bibformat_2hal(request, csvfile): msg_to_announce = "Après l'opération, les résultats seront envoyés à l'adresse : {0}".format(mail_reponse) messages.add_message(request, messages.WARNING, msg_to_announce) - reponse = sendselect_2hal.delay(name_user,login_user,id_hal_user,mail_reponse,labo_auth_final,listdomains,login_depot,passwd_depot,choice_depot,list_publis_to_update,csvfile) + reponse = sendselect_2hal.delay(firstname_user,name_user,login_user,id_hal_user,mail_reponse,labo_auth_final,listdomains,login_depot,passwd_depot,choice_depot,list_publis_to_update,csvfile) return render(request, 'hal/bibformat_2hal.html', locals())