From 9d6e8821997a830a6e86976c58a6473de7938fcc Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sat, 10 Jul 2021 17:40:40 +0200 Subject: [PATCH] xml without jaxml --- app/scodoc/sco_bulletins_xml.py | 21 +++++++++++++-------- app/scodoc/sco_groups.py | 1 - app/scodoc/sco_recapcomplet.py | 29 +++++++++++++++-------------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/app/scodoc/sco_bulletins_xml.py b/app/scodoc/sco_bulletins_xml.py index 52c98e33..6cb548c3 100644 --- a/app/scodoc/sco_bulletins_xml.py +++ b/app/scodoc/sco_bulletins_xml.py @@ -106,8 +106,10 @@ def make_xml_formsemestre_bulletinetud( x = Element("bulletinetud", **el) if doc: + is_appending = True doc.append(x) else: + is_appending = False doc = x # Infos sur l'etudiant etudinfo = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] @@ -424,12 +426,15 @@ def make_xml_formsemestre_bulletinetud( apprecs = sco_etud.appreciations_list( cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id} ) - for app in apprecs: - doc.append( - Element( - "appreciation", - scu.quote_xml_attr(app["comment"]), - date=ndb.DateDMYtoISO(app["date"]), - ) + for appr in apprecs: + x_appr = Element( + "appreciation", + date=ndb.DateDMYtoISO(appr["date"]), ) - return sco_xml.XML_HEADER + ElementTree.tostring(doc) + x_appr.text = scu.quote_xml_attr(appr["comment"]) + doc.append(x_appr) + + if is_appending: + return None + else: + return sco_xml.XML_HEADER + ElementTree.tostring(doc) diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py index d2ca6776..96b49e60 100644 --- a/app/scodoc/sco_groups.py +++ b/app/scodoc/sco_groups.py @@ -43,7 +43,6 @@ import xml.dom.minidom from xml.etree import ElementTree from xml.etree.ElementTree import Element - import app.scodoc.sco_utils as scu import app.scodoc.notesdb as ndb from app.scodoc.notes_log import log diff --git a/app/scodoc/sco_recapcomplet.py b/app/scodoc/sco_recapcomplet.py index 88b17a65..46b93915 100644 --- a/app/scodoc/sco_recapcomplet.py +++ b/app/scodoc/sco_recapcomplet.py @@ -29,7 +29,7 @@ """ import time import datetime -import jaxml +from xml.etree import ElementTree import app.scodoc.sco_utils as scu from app.scodoc.notes_log import log @@ -50,6 +50,7 @@ from app.scodoc import sco_permissions_check from app.scodoc import sco_preferences from app.scodoc import sco_etud from app.scodoc import sco_users +from app.scodoc import sco_xml from app.scodoc.sco_codes_parcours import DEF, UE_SPORT @@ -876,24 +877,25 @@ def _formsemestre_recapcomplet_xml( if not T: return "", "", "xml" - doc = jaxml.XML_document(encoding=scu.SCO_ENCODING) if xml_nodate: docdate = "" else: docdate = datetime.datetime.now().isoformat() - doc.recapsemestre(formsemestre_id=formsemestre_id, date=docdate) - evals = sco_evaluations.do_evaluation_etat_in_sem(context, formsemestre_id) - doc._push() - doc.evals_info( - nb_evals_completes=evals["nb_evals_completes"], - nb_evals_en_cours=evals["nb_evals_en_cours"], - nb_evals_vides=evals["nb_evals_vides"], - date_derniere_note=evals["last_modif"], + doc = ElementTree.Element( + "recapsemestre", formsemestre_id=formsemestre_id, date=docdate + ) + evals = sco_evaluations.do_evaluation_etat_in_sem(context, formsemestre_id) + doc.append( + ElementTree.Element( + "evals_info", + nb_evals_completes=str(evals["nb_evals_completes"]), + nb_evals_en_cours=str(evals["nb_evals_en_cours"]), + nb_evals_vides=str(evals["nb_evals_vides"]), + date_derniere_note=str(evals["last_modif"]), + ) ) - doc._pop() for t in T: etudid = t[-1] - doc._push() sco_bulletins_xml.make_xml_formsemestre_bulletinetud( context, formsemestre_id, @@ -903,8 +905,7 @@ def _formsemestre_recapcomplet_xml( xml_nodate=xml_nodate, xml_with_decisions=xml_with_decisions, ) - doc._pop() - return repr(doc), "", "xml" + return sco_xml.XML_HEADER + ElementTree.tostring(doc), "", "xml" def _formsemestre_recapcomplet_json(