From d71cde11717e8c013ca1498e51c03fad9f2aeb8b Mon Sep 17 00:00:00 2001 From: fram3d Date: Thu, 18 Jan 2024 22:41:26 +0100 Subject: [PATCH] check if user already added to task --- build-deb/taskmanager/DEBIAN/control | 2 +- taskmanager/routes.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/build-deb/taskmanager/DEBIAN/control b/build-deb/taskmanager/DEBIAN/control index c18d91d..0f953e2 100644 --- a/build-deb/taskmanager/DEBIAN/control +++ b/build-deb/taskmanager/DEBIAN/control @@ -8,4 +8,4 @@ Depends: gunicorn, python3-flask-sqlalchemy Homepage: https://gitea.dmz.rs/Decentrala/taskmanager Maintainer: Decentrala Description: Interactive TODO list Web app -Version: 1.0.3 +Version: 1.0.5 diff --git a/taskmanager/routes.py b/taskmanager/routes.py index 25775f3..05fba99 100644 --- a/taskmanager/routes.py +++ b/taskmanager/routes.py @@ -107,6 +107,13 @@ def project(task_id:int): return 'User not found, please register.' if userid is None: return 'User not found, please register.' + # check if user already added + try: + existinguser = TaskUser.query.filter_by(userid = userid, taskid = taskid ).first().userid + except: + existingusers = None + if existingusers == userid : + return "User already added" sqladduser = TaskUser(userid = userid, taskid = task_id) try: db.session.add(sqladduser)