fix check for already added users to task

This commit is contained in:
fram3d 2024-01-18 22:53:35 +01:00
parent d71cde1171
commit 4911842d3f
Signed by: fram3d
GPG Key ID: 938920E709EEA32A
2 changed files with 4 additions and 10 deletions

View File

@ -8,4 +8,4 @@ Depends: gunicorn, python3-flask-sqlalchemy
Homepage: https://gitea.dmz.rs/Decentrala/taskmanager
Maintainer: Decentrala <dmz@dmz.rs>
Description: Interactive TODO list Web app
Version: 1.0.5
Version: 1.0.6

View File

@ -99,7 +99,8 @@ 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:
for user in users:
if username == user.username:
return 'User already added to task'
try:
userid = User.query.filter_by(username = username).first().id
@ -107,13 +108,6 @@ def project(task_id:int):
return 'User not found, please <a href="/register">register</a>.'
if userid is None:
return 'User not found, please <a href="/register">register</a>.'
# 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)