From 7bc5a5ffd1547ef2e339b57f269d6b1fc7324ef6 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 25 Aug 2022 18:48:48 +0200 Subject: [PATCH] Fix #362 --- app/views/scolar.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/views/scolar.py b/app/views/scolar.py index 50ede9e7..9b6388a7 100644 --- a/app/views/scolar.py +++ b/app/views/scolar.py @@ -693,16 +693,18 @@ sco_publish( @scodoc7func def doAddAnnotation(etudid, comment): "ajoute annotation sur etudiant" - cnx = ndb.GetDBConnexion() - sco_etud.etud_annotations_create( - cnx, - args={ - "etudid": etudid, - "comment": comment, - "author": current_user.user_name, - }, - ) - logdb(cnx, method="addAnnotation", etudid=etudid) + etud = Identite.query.get_or_404(etudid) # check existence + if comment: + cnx = ndb.GetDBConnexion() + sco_etud.etud_annotations_create( + cnx, + args={ + "etudid": etudid, + "comment": comment, + "author": current_user.user_name, + }, + ) + logdb(cnx, method="addAnnotation", etudid=etudid) return flask.redirect( url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid) )