From 4911842d3f5759e971db787ae1d17d2839172046 Mon Sep 17 00:00:00 2001 From: fram3d Date: Thu, 18 Jan 2024 22:53:35 +0100 Subject: [PATCH] fix check for already added users to task --- build-deb/taskmanager/DEBIAN/control | 2 +- taskmanager/routes.py | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/build-deb/taskmanager/DEBIAN/control b/build-deb/taskmanager/DEBIAN/control index 0f953e2..12588d2 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.5 +Version: 1.0.6 diff --git a/taskmanager/routes.py b/taskmanager/routes.py index 05fba99..a491f5a 100644 --- a/taskmanager/routes.py +++ b/taskmanager/routes.py @@ -99,21 +99,15 @@ def project(task_id:int): username = request.form['username'] if len(username) < 1 or len(username) > 40: return "Username lenght invalid, only smaller then 40 charachters allowed" - if username in users: - return 'User already added to task' + for user in users: + if username == user.username: + return 'User already added to task' try: userid = User.query.filter_by(username = username).first().id except: 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)