From: Agnibho Mondal Date: Thu, 14 Mar 2024 15:46:30 +0000 (+0530) Subject: Mark administered X-Git-Url: https://code.agnibho.com/repo?a=commitdiff_plain;h=c692b76fd6bf794ab1b18f05199499d9539daa36;p=librevax.git Mark administered --- diff --git a/librevax.py b/librevax.py index fb0f0f9..86498df 100644 --- a/librevax.py +++ b/librevax.py @@ -654,6 +654,19 @@ def vaccination_edit(vid=None, pid=None): raise(e) return render_template("error.html", data=e) +@app.post("/mark") +def mark(): + if((ret:=problem())!="go"): + return ret + try: + cursor=get_db().cursor() + (ok, data)=vaccination.mark(cursor, request.form["vid"], True) + if(not ok): + raise Exception(data) + return redirect("/vaccination/view/"+str(request.form["vid"])) + except Exception as e: + raise(e) + return render_template("error.html", data=e) @app.get("/advice/") @app.get("/advice//") diff --git a/templates/vaccination-view.html b/templates/vaccination-view.html index 47057af..2ff7792 100644 --- a/templates/vaccination-view.html +++ b/templates/vaccination-view.html @@ -49,7 +49,9 @@ You should have received a copy of the GNU General Public License along with Lib Edit Delete - + {%if not data["given"]%} +
+ {%endif%} {% endif %} diff --git a/vaccination.py b/vaccination.py index 34abbb9..a92f3cc 100644 --- a/vaccination.py +++ b/vaccination.py @@ -45,6 +45,16 @@ def delete(cursor, vid): except Exception as e: return (False, e) +def mark(cursor, vid, given): + try: + cursor.execute("UPDATE vaccination SET given=? WHERE vid=?", (given, vid)) + if(cursor.rowcount==0): + return (False, "Failed to update record.") + else: + return (True, cursor.lastrowid) + except Exception as e: + return (False, e) + def list_by_patient(cursor, pid): try: result=cursor.execute("SELECT * FROM vaccination LEFT JOIN inventory ON vaccination.iid=inventory.iid WHERE pid=? ORDER BY vaccination.date", (pid,))