Fix: erreur suppr

This commit is contained in:
Éric Li 2021-06-14 18:44:17 +02:00
parent 0c5345f171
commit 835990a81e

View File

@ -7,6 +7,7 @@ import app.models as models
@app.route("/index", methods=["GET","POST"]) @app.route("/index", methods=["GET","POST"])
def index(): def index():
form = AccueilForm() form = AccueilForm()
valide = form.validate_on_submit()
if form.ajouter.data: if form.ajouter.data:
for i in range(1,7): for i in range(1,7):
semestre = models.Semestre(num=i) semestre = models.Semestre(num=i)
@ -20,6 +21,8 @@ def index():
form.exportJSON() form.exportJSON()
elif form.exporterYAML.data: elif form.exporterYAML.data:
form.exportYAML() form.exportYAML()
elif form.importer.data and valide:
form.importRef()
semestres = sorted(models.Semestre.query.all(), key=lambda semestre: semestre.num) semestres = sorted(models.Semestre.query.all(), key=lambda semestre: semestre.num)
return render_template("index.html", semestres=semestres, form=form) return render_template("index.html", semestres=semestres, form=form)
@ -68,7 +71,7 @@ def Semestre(num):
codeClass, code = coeffield.objetformation.data[1:-1].split() codeClass, code = coeffield.objetformation.data[1:-1].split()
model = getattr(models, codeClass) model = getattr(models, codeClass)
objetformation = model.query.filter_by(code=code).first() objetformation = model.query.filter_by(code=code).first()
if objetformation in querySAE or objetformation in queryRessource: if objetformation in list(set(querySAE)&set(field.saes.data)) or objetformation in list(set(queryRessource)&set(field.ressources.data)):
objetformation.setCoef(coeffield.coef.data, ue) objetformation.setCoef(coeffield.coef.data, ue)
db.session.commit() db.session.commit()
return redirect(url_for("Semestre", num=num)) return redirect(url_for("Semestre", num=num))