From 972ad7964fe2a44bf041b45877014b3240105e1b Mon Sep 17 00:00:00 2001 From: Agnibho Mondal Date: Fri, 12 Jan 2024 02:00:26 +0530 Subject: [PATCH] Bugfix: add personnel --- personnel.py | 10 ++++++++-- templates/personnel-edit.html | 4 ++-- templates/personnel-view.html | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/personnel.py b/personnel.py index b2dbb20..75ace87 100644 --- a/personnel.py +++ b/personnel.py @@ -7,7 +7,10 @@ def create(cursor, data, active): try: - cursor.execute("INSERT INTO personnel (cid, mid, name, designation, contact, role, info, active) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", (data["cid"], data["mid"], data["name"], data["designation"], data["contact"], data["role"], data["info"], active)) + cid=None + if(data["cid"]!=""): + cid=data["cid"] + cursor.execute("INSERT INTO personnel (cid, mid, name, designation, contact, role, info, active) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", (cid, data["mid"], data["name"], data["designation"], data["contact"], data["role"], data["info"], active)) if(cursor.rowcount<=0): return (False, "Failed to create record.") else: @@ -25,7 +28,10 @@ def read(cursor, sid): def update(cursor, sid, data, active): try: - cursor.execute("UPDATE personnel SET cid=?, mid=?, name=?, designation=?, contact=?, role=?, info=?, active=? WHERE sid=?", (data["cid"], data["mid"], data["name"], data["designation"], data["contact"], data["role"], data["info"], active, sid)) + cid=None + if(data["cid"]!=""): + cid=data["cid"] + cursor.execute("UPDATE personnel SET cid=?, mid=?, name=?, designation=?, contact=?, role=?, info=?, active=? WHERE sid=?", (cid, data["mid"], data["name"], data["designation"], data["contact"], data["role"], data["info"], active, sid)) if(cursor.rowcount<=0): return (False, "Failed to update record.") else: diff --git a/templates/personnel-edit.html b/templates/personnel-edit.html index 019a841..21ed53c 100644 --- a/templates/personnel-edit.html +++ b/templates/personnel-edit.html @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with Lib
- +
@@ -52,7 +52,7 @@ You should have received a copy of the GNU General Public License along with Lib
- {% for i in center %} diff --git a/templates/personnel-view.html b/templates/personnel-view.html index 0f19643..fb859bc 100644 --- a/templates/personnel-view.html +++ b/templates/personnel-view.html @@ -28,7 +28,7 @@ You should have received a copy of the GNU General Public License along with Lib {% endif %} - {% if action=="view" and data["mid"] %} + {% if action=="view" %} -- 2.39.5