From 42334c794636fc9a2e49ac42597340a3fcf189db Mon Sep 17 00:00:00 2001 From: Nekori Date: Fri, 7 May 2021 12:58:38 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20Charger:=20donn=C3=A9es=20qui=20s'affiche?= =?UTF-8?q?=20pas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/forms.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/forms.py b/app/forms.py index 1cc683b..bb0146a 100644 --- a/app/forms.py +++ b/app/forms.py @@ -29,7 +29,7 @@ class PNForm(Form): nom = StringField("Nom", validators=[DataRequired()] ) diminutif = StringField("Diminutif", validators=[DataRequired()] ) description = TextAreaField("Description", validators=[DataRequired()] ) - type = RadioField("Type", choices=[1,2,3], validators=[DataRequired()]) + type = RadioField("Type", choices=["1","2","3"], validators=[DataRequired()]) class ACForm(Form): regex = "^AC\d{4}$" @@ -93,17 +93,15 @@ def form_import(form): return form fichier_Yaml = yaml.safe_load(form.fichier.data.read()) for categorie, valeur in fichier_Yaml.items(): - form[categorie].data = valeur + form[categorie].process_data(valeur) form.validate_on_submit() # RĂ©initialise les messages d'erreur return form def form_export(form): """ Si le formulaire est valide => exporte dans un fichier yaml avec les informations du formulaire """ output = {} - for categorie, valeur in list(form.data.items())[6:-1]: output[categorie] = valeur - fichier = REPERTOIRE_YAML + form.code.data + ".yml" with open(fichier, "w", encoding="utf8") as fid: fid.write(yaml.dump(output)) @@ -118,6 +116,6 @@ def form_charger(form): model = getattr(models, temp[0]) referentiel = model.query.filter_by(code=temp[1]).first() for categorie in list(referentiel.__dict__)[1:]: - form[categorie].data = referentiel.__dict__[categorie] + form[categorie].process_data(referentiel.__dict__[categorie]) form.validate_on_submit() return form \ No newline at end of file