fix check for already added users to task
This commit is contained in:
parent
d71cde1171
commit
4911842d3f
@ -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
|
||||
|
@ -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 <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)
|
||||
|
Loading…
Reference in New Issue
Block a user