Fix Charger: données qui s'affiche pas
This commit is contained in:
parent
18269242b8
commit
42334c7946
@ -29,7 +29,7 @@ class PNForm(Form):
|
|||||||
nom = StringField("Nom", validators=[DataRequired()] )
|
nom = StringField("Nom", validators=[DataRequired()] )
|
||||||
diminutif = StringField("Diminutif", validators=[DataRequired()] )
|
diminutif = StringField("Diminutif", validators=[DataRequired()] )
|
||||||
description = TextAreaField("Description", 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):
|
class ACForm(Form):
|
||||||
regex = "^AC\d{4}$"
|
regex = "^AC\d{4}$"
|
||||||
@ -93,17 +93,15 @@ def form_import(form):
|
|||||||
return form
|
return form
|
||||||
fichier_Yaml = yaml.safe_load(form.fichier.data.read())
|
fichier_Yaml = yaml.safe_load(form.fichier.data.read())
|
||||||
for categorie, valeur in fichier_Yaml.items():
|
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
|
form.validate_on_submit() # Réinitialise les messages d'erreur
|
||||||
return form
|
return form
|
||||||
|
|
||||||
def form_export(form):
|
def form_export(form):
|
||||||
""" Si le formulaire est valide => exporte dans un fichier yaml avec les informations du formulaire """
|
""" Si le formulaire est valide => exporte dans un fichier yaml avec les informations du formulaire """
|
||||||
output = {}
|
output = {}
|
||||||
|
|
||||||
for categorie, valeur in list(form.data.items())[6:-1]:
|
for categorie, valeur in list(form.data.items())[6:-1]:
|
||||||
output[categorie] = valeur
|
output[categorie] = valeur
|
||||||
|
|
||||||
fichier = REPERTOIRE_YAML + form.code.data + ".yml"
|
fichier = REPERTOIRE_YAML + form.code.data + ".yml"
|
||||||
with open(fichier, "w", encoding="utf8") as fid:
|
with open(fichier, "w", encoding="utf8") as fid:
|
||||||
fid.write(yaml.dump(output))
|
fid.write(yaml.dump(output))
|
||||||
@ -118,6 +116,6 @@ def form_charger(form):
|
|||||||
model = getattr(models, temp[0])
|
model = getattr(models, temp[0])
|
||||||
referentiel = model.query.filter_by(code=temp[1]).first()
|
referentiel = model.query.filter_by(code=temp[1]).first()
|
||||||
for categorie in list(referentiel.__dict__)[1:]:
|
for categorie in list(referentiel.__dict__)[1:]:
|
||||||
form[categorie].data = referentiel.__dict__[categorie]
|
form[categorie].process_data(referentiel.__dict__[categorie])
|
||||||
form.validate_on_submit()
|
form.validate_on_submit()
|
||||||
return form
|
return form
|
Loading…
Reference in New Issue
Block a user