check if user already added to task

This commit is contained in:
fram3d 2024-01-18 22:41:26 +01:00
parent e615f774ad
commit d71cde1171
Signed by: fram3d
GPG Key ID: 938920E709EEA32A
2 changed files with 8 additions and 1 deletions

View File

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

View File

@ -107,6 +107,13 @@ def project(task_id:int):
return 'User not found, please <a href="/register">register</a>.' return 'User not found, please <a href="/register">register</a>.'
if userid is None: if userid is None:
return 'User not found, please <a href="/register">register</a>.' 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) sqladduser = TaskUser(userid = userid, taskid = task_id)
try: try:
db.session.add(sqladduser) db.session.add(sqladduser)