forked from ScoDoc/ScoDoc
Export formation: fix regression and sort xml attributes to get stable results
This commit is contained in:
parent
8feff2b182
commit
abd8bf484d
@ -125,7 +125,7 @@ def formation_export_dict(
|
||||
mat = db.session.get(Matiere, matiere_id)
|
||||
mods = mat.modules.all()
|
||||
mods.sort(key=lambda m: (m.numero, m.code))
|
||||
mat_d["module"] = [mod.to_dict() for mod in mods]
|
||||
mat_d["module"] = [mod.to_dict(convert_objects=True) for mod in mods]
|
||||
for module, mod_d in zip(mods, mat_d["module"]):
|
||||
if export_tags:
|
||||
tags = [t.title for t in module.tags]
|
||||
@ -228,11 +228,10 @@ def _formation_retreive_refcomp(f_dict: dict) -> int:
|
||||
).first()
|
||||
if refcomp:
|
||||
return refcomp.id
|
||||
else:
|
||||
flash(
|
||||
f"""Impossible de trouver le référentiel de compétence pour {
|
||||
refcomp_specialite} : est-il chargé ?"""
|
||||
)
|
||||
flash(
|
||||
f"""Impossible de trouver le référentiel de compétence pour {
|
||||
refcomp_specialite} : est-il chargé ?"""
|
||||
)
|
||||
return None
|
||||
|
||||
|
||||
|
@ -107,24 +107,20 @@ def _dictlist2xml(dictlist, root=None, tagname=None, quote=False):
|
||||
elem.set("code", _repr_as_xml(d))
|
||||
else:
|
||||
if quote:
|
||||
d_scalar = dict(
|
||||
[
|
||||
(k, quote_xml_attr(_repr_as_xml(v)))
|
||||
for (k, v) in d.items()
|
||||
if isinstance(v, scalar_types)
|
||||
]
|
||||
)
|
||||
d_scalar = {
|
||||
k: quote_xml_attr(_repr_as_xml(v))
|
||||
for (k, v) in d.items()
|
||||
if isinstance(v, scalar_types)
|
||||
}
|
||||
else:
|
||||
d_scalar = dict(
|
||||
[
|
||||
(k, _repr_as_xml(v))
|
||||
for (k, v) in d.items()
|
||||
if isinstance(v, scalar_types)
|
||||
]
|
||||
)
|
||||
for k in d_scalar:
|
||||
elem.set(k, d_scalar[k])
|
||||
d_list = dict([(k, v) for (k, v) in d.items() if isinstance(v, list)])
|
||||
d_scalar = {
|
||||
k: _repr_as_xml(v)
|
||||
for (k, v) in d.items()
|
||||
if isinstance(v, scalar_types)
|
||||
}
|
||||
for k, v in sorted(d_scalar.items()):
|
||||
elem.set(k, v)
|
||||
d_list = {k: v for (k, v) in d.items() if isinstance(v, list)}
|
||||
if d_list:
|
||||
for k, v in d_list.items():
|
||||
_dictlist2xml(v, tagname=k, root=elem, quote=quote)
|
||||
|
Loading…
Reference in New Issue
Block a user