Ajout ExportYAML

This commit is contained in:
Éric Li 2021-06-09 12:37:57 +02:00
parent d7d30e43dd
commit f5e435c267

View File

@ -59,6 +59,17 @@ class AccueilForm(FlaskForm):
with open(fichier, "w", encoding="utf8") as fid: with open(fichier, "w", encoding="utf8") as fid:
json.dump(result, fid, cls=CustomEncoder, indent=4) 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): class CoefForm(FlaskForm):
objetformation = HiddenField("Objet de formation") objetformation = HiddenField("Objet de formation")
coef = StringField("Coef") coef = StringField("Coef")