From f5e435c267a8c52ada83b839dcd93cf58232ab36 Mon Sep 17 00:00:00 2001 From: Nekori Date: Wed, 9 Jun 2021 12:37:57 +0200 Subject: [PATCH] Ajout ExportYAML --- app/forms.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/forms.py b/app/forms.py index 3959242..7e713e5 100644 --- a/app/forms.py +++ b/app/forms.py @@ -59,6 +59,17 @@ class AccueilForm(FlaskForm): with open(fichier, "w", encoding="utf8") as fid: json.dump(result, fid, cls=CustomEncoder, indent=4) + def exportYAML(self): + result = {"semestres": [], "competences": [], "acs": [], "pns": [], "saes": [], "coefsaes": [], "ressources": [], "coefressources": []} + for key in result.keys(): + model = getattr(models, categorie_to_model[key]) + for ref in model.query.all(): + result[key].append(ref.export()) + fichier = REPERTOIRE_EXPORT + "referentiels" + ".yml" + with open(fichier, "w", encoding="utf8") as fid: + yaml.dump(yaml.safe_load(json.dumps(result, cls=CustomEncoder)), fid, indent=4) + + class CoefForm(FlaskForm): objetformation = HiddenField("Objet de formation") coef = StringField("Coef")