xml without jaxml

This commit is contained in:
Emmanuel Viennet 2021-07-10 17:40:40 +02:00
parent ec8bef7984
commit 9d6e882199
3 changed files with 28 additions and 23 deletions

View File

@ -106,8 +106,10 @@ def make_xml_formsemestre_bulletinetud(
x = Element("bulletinetud", **el) x = Element("bulletinetud", **el)
if doc: if doc:
is_appending = True
doc.append(x) doc.append(x)
else: else:
is_appending = False
doc = x doc = x
# Infos sur l'etudiant # Infos sur l'etudiant
etudinfo = sco_etud.get_etud_info(etudid=etudid, filled=1)[0] 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( apprecs = sco_etud.appreciations_list(
cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id} cnx, args={"etudid": etudid, "formsemestre_id": formsemestre_id}
) )
for app in apprecs: for appr in apprecs:
doc.append( x_appr = Element(
Element(
"appreciation", "appreciation",
scu.quote_xml_attr(app["comment"]), date=ndb.DateDMYtoISO(appr["date"]),
date=ndb.DateDMYtoISO(app["date"]),
)
) )
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) return sco_xml.XML_HEADER + ElementTree.tostring(doc)

View File

@ -43,7 +43,6 @@ import xml.dom.minidom
from xml.etree import ElementTree from xml.etree import ElementTree
from xml.etree.ElementTree import Element from xml.etree.ElementTree import Element
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
import app.scodoc.notesdb as ndb import app.scodoc.notesdb as ndb
from app.scodoc.notes_log import log from app.scodoc.notes_log import log

View File

@ -29,7 +29,7 @@
""" """
import time import time
import datetime import datetime
import jaxml from xml.etree import ElementTree
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
from app.scodoc.notes_log import log 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_preferences
from app.scodoc import sco_etud from app.scodoc import sco_etud
from app.scodoc import sco_users from app.scodoc import sco_users
from app.scodoc import sco_xml
from app.scodoc.sco_codes_parcours import DEF, UE_SPORT from app.scodoc.sco_codes_parcours import DEF, UE_SPORT
@ -876,24 +877,25 @@ def _formsemestre_recapcomplet_xml(
if not T: if not T:
return "", "", "xml" return "", "", "xml"
doc = jaxml.XML_document(encoding=scu.SCO_ENCODING)
if xml_nodate: if xml_nodate:
docdate = "" docdate = ""
else: else:
docdate = datetime.datetime.now().isoformat() docdate = datetime.datetime.now().isoformat()
doc.recapsemestre(formsemestre_id=formsemestre_id, date=docdate) doc = ElementTree.Element(
evals = sco_evaluations.do_evaluation_etat_in_sem(context, formsemestre_id) "recapsemestre", formsemestre_id=formsemestre_id, date=docdate
doc._push() )
doc.evals_info( evals = sco_evaluations.do_evaluation_etat_in_sem(context, formsemestre_id)
nb_evals_completes=evals["nb_evals_completes"], doc.append(
nb_evals_en_cours=evals["nb_evals_en_cours"], ElementTree.Element(
nb_evals_vides=evals["nb_evals_vides"], "evals_info",
date_derniere_note=evals["last_modif"], 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: for t in T:
etudid = t[-1] etudid = t[-1]
doc._push()
sco_bulletins_xml.make_xml_formsemestre_bulletinetud( sco_bulletins_xml.make_xml_formsemestre_bulletinetud(
context, context,
formsemestre_id, formsemestre_id,
@ -903,8 +905,7 @@ def _formsemestre_recapcomplet_xml(
xml_nodate=xml_nodate, xml_nodate=xml_nodate,
xml_with_decisions=xml_with_decisions, xml_with_decisions=xml_with_decisions,
) )
doc._pop() return sco_xml.XML_HEADER + ElementTree.tostring(doc), "", "xml"
return repr(doc), "", "xml"
def _formsemestre_recapcomplet_json( def _formsemestre_recapcomplet_json(