forked from ScoDoc/DocScoDoc
misc fixes
This commit is contained in:
parent
76b533729f
commit
ce36edd86d
@ -113,6 +113,11 @@ Pour créer un utilisateur "super admin", c'est à dire admin dans tous les dép
|
||||
|
||||
python -m unittest tests.test_users
|
||||
|
||||
|
||||
# TODO
|
||||
|
||||
- page d'erreur ScoValueError
|
||||
- redirection pour authentification
|
||||
- import/export Excel
|
||||
|
||||
|
||||
|
||||
|
@ -42,6 +42,7 @@ from app.scodoc import sco_formsemestre
|
||||
from app.scodoc import sco_news
|
||||
from app.scodoc import sco_preferences
|
||||
from app.scodoc import sco_tag_module
|
||||
from app.scodoc import sco_xml
|
||||
from app.scodoc import VERSION
|
||||
from app.scodoc.gen_tables import GenTable
|
||||
from app.scodoc.sco_exceptions import ScoValueError
|
||||
@ -133,35 +134,7 @@ def formation_export(
|
||||
)
|
||||
|
||||
|
||||
ELEMENT_NODE = 1
|
||||
TEXT_NODE = 3
|
||||
|
||||
|
||||
def XMLToDicts(element, encoding):
|
||||
"""Represent dom element as a dict
|
||||
Example:
|
||||
<foo x="1" y="2"><bar z="2"/></foo>
|
||||
will give us:
|
||||
('foo', {'y': '2', 'x': '1'}, [('bar', {'z': '2'}, [])])
|
||||
"""
|
||||
d = {}
|
||||
# attributes
|
||||
if element.attributes:
|
||||
for i in range(len(element.attributes)):
|
||||
a = element.attributes.item(i).nodeName.encode(encoding)
|
||||
v = element.getAttribute(element.attributes.item(i).nodeName)
|
||||
d[a] = v.encode(encoding)
|
||||
# descendants
|
||||
childs = []
|
||||
for child in element.childNodes:
|
||||
if child.nodeType == ELEMENT_NODE:
|
||||
childs.append(XMLToDicts(child, encoding))
|
||||
return (element.nodeName.encode(encoding), d, childs)
|
||||
|
||||
|
||||
def formation_import_xml(
|
||||
context, REQUEST, doc, import_tags=True, encoding=scu.SCO_ENCODING
|
||||
):
|
||||
def formation_import_xml(context, REQUEST, doc, import_tags=True):
|
||||
"""Create a formation from XML representation
|
||||
(format dumped by formation_export( format='xml' ))
|
||||
"""
|
||||
@ -175,7 +148,7 @@ def formation_import_xml(
|
||||
raise ScoValueError("Fichier XML invalide")
|
||||
|
||||
f = dom.getElementsByTagName("formation")[0] # or dom.documentElement
|
||||
D = XMLToDicts(f, encoding)
|
||||
D = sco_xml.xml_to_dicts(f)
|
||||
assert D[0] == "formation"
|
||||
F = D[1]
|
||||
F_quoted = F.copy()
|
||||
|
@ -462,7 +462,7 @@ def build_page(
|
||||
|
||||
def formsemestre_inscr_passage_help(sem):
|
||||
return (
|
||||
"""<div class="pas_help pas_help_left"><h3><a name="help">Explications</a></h3>
|
||||
"""<div class="pas_help"><h3><a name="help">Explications</a></h3>
|
||||
<p>Cette page permet d'inscrire des étudiants dans le semestre destination
|
||||
<a class="stdlink"
|
||||
href="formsemestre_status?formsemestre_id=%(formsemestre_id)s">%(titreannee)s</a>,
|
||||
|
@ -96,3 +96,29 @@ def _dictlist2xml(dictlist, root=None, tagname=None, quote=False):
|
||||
for (k, v) in d_list.items():
|
||||
_dictlist2xml(v, tagname=k, root=elem, quote=quote)
|
||||
return root
|
||||
|
||||
|
||||
ELEMENT_NODE = 1
|
||||
TEXT_NODE = 3
|
||||
|
||||
|
||||
def xml_to_dicts(element):
|
||||
"""Represent dom element as a dict
|
||||
Example:
|
||||
<foo x="1" y="2"><bar z="2"/></foo>
|
||||
will give us:
|
||||
('foo', {'y': '2', 'x': '1'}, [('bar', {'z': '2'}, [])])
|
||||
"""
|
||||
d = {}
|
||||
# attributes
|
||||
if element.attributes:
|
||||
for i in range(len(element.attributes)):
|
||||
a = element.attributes.item(i).nodeName
|
||||
v = element.getAttribute(element.attributes.item(i).nodeName)
|
||||
d[a] = v
|
||||
# descendants
|
||||
childs = []
|
||||
for child in element.childNodes:
|
||||
if child.nodeType == ELEMENT_NODE:
|
||||
childs.append(xml_to_dicts(child))
|
||||
return (element.nodeName, d, childs)
|
@ -251,11 +251,13 @@ sco_publish(
|
||||
"/formsemestre_delete",
|
||||
sco_formsemestre_edit.formsemestre_delete,
|
||||
Permission.ScoImplement,
|
||||
methods=["GET", "POST"],
|
||||
)
|
||||
sco_publish(
|
||||
"/formsemestre_delete2",
|
||||
sco_formsemestre_edit.formsemestre_delete2,
|
||||
Permission.ScoImplement,
|
||||
methods=["GET", "POST"],
|
||||
)
|
||||
sco_publish(
|
||||
"/formsemestre_recapcomplet",
|
||||
@ -2170,7 +2172,7 @@ def formsemestre_fix_validation_ues(context, formsemestre_id, REQUEST=None):
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/formsemestre_validation_suppress_etud")
|
||||
@bp.route("/formsemestre_validation_suppress_etud", methods=["GET", "POST"])
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func(context)
|
||||
def formsemestre_validation_suppress_etud(
|
||||
|
Loading…
Reference in New Issue
Block a user