diff --git a/README.md b/README.md index 4d149d039..e4afee00b 100644 --- a/README.md +++ b/README.md @@ -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 + diff --git a/app/scodoc/sco_formations.py b/app/scodoc/sco_formations.py index e4ac0acb8..b41c481ca 100644 --- a/app/scodoc/sco_formations.py +++ b/app/scodoc/sco_formations.py @@ -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: - - 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() diff --git a/app/scodoc/sco_inscr_passage.py b/app/scodoc/sco_inscr_passage.py index c107289aa..8dcfabaa6 100644 --- a/app/scodoc/sco_inscr_passage.py +++ b/app/scodoc/sco_inscr_passage.py @@ -462,7 +462,7 @@ def build_page( def formsemestre_inscr_passage_help(sem): return ( - """

Explications

+ """

Explications

Cette page permet d'inscrire des étudiants dans le semestre destination %(titreannee)s, diff --git a/app/scodoc/sco_xml.py b/app/scodoc/sco_xml.py index f5a08a55b..d7ec39b2d 100644 --- a/app/scodoc/sco_xml.py +++ b/app/scodoc/sco_xml.py @@ -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: + + 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) \ No newline at end of file diff --git a/app/views/notes.py b/app/views/notes.py index 3fc7bd5b2..470fb417c 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -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(