fix taskuser delition after removing tasks and repsonse.html
This commit is contained in:
parent
44b7228982
commit
13d1e1674d
@ -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.9
|
||||
Version: 1.0.10
|
||||
|
@ -26,7 +26,7 @@ def addtask():
|
||||
username = request.form['username']
|
||||
# Input sanitation
|
||||
# Task name
|
||||
if not taskname.isalnum():
|
||||
if not taskname.isprintable():
|
||||
return render_template('response.html', response = "Task name has to be made only of letters or numbers.")
|
||||
if len(taskname) < 1 or len(taskname) > 40:
|
||||
return render_template('response.html', response = "Task name lenght invalid, only smaller then 40 charachters allowed")
|
||||
@ -38,9 +38,9 @@ def addtask():
|
||||
try:
|
||||
creatorid = User.query.filter_by(username = username).first().id
|
||||
except:
|
||||
return render_template('response.html', response = 'No user with this username. Please <a href="/register">register</a>.')
|
||||
return render_template('response.html', response = 'No user with this username. Please register')
|
||||
if creatorid is None:
|
||||
return render_template('response.html', response = 'No user with this username. Please <a href="/register">register</a>.')
|
||||
return render_template('response.html', response = 'No user with this username. Please register.')
|
||||
|
||||
# Task descripton
|
||||
if taskdesc != '':
|
||||
@ -117,9 +117,9 @@ def project(task_id:int):
|
||||
try:
|
||||
userid = User.query.filter_by(username = username).first().id
|
||||
except:
|
||||
return render_template('response.html', response = 'User not found, please <a href="/register">register</a>.')
|
||||
return render_template('response.html', response = 'User not found, please register.')
|
||||
if userid is None:
|
||||
return render_template('response.html', response = 'User not found, please <a href="/register">register</a>.')
|
||||
return render_template('response.html', response = 'User not found, please register.')
|
||||
sqladduser = TaskUser(userid = userid, taskid = task_id)
|
||||
try:
|
||||
db.session.add(sqladduser)
|
||||
@ -134,24 +134,28 @@ def deltask(task_id:int):
|
||||
task = Task.query.get(task_id)
|
||||
except:
|
||||
return render_template('response.html', response = 'Task not found, bad URL')
|
||||
try:
|
||||
taskusers = TaskUser.query.filter_by(task_id = task_id)
|
||||
except:
|
||||
taskusers = None
|
||||
if task is None:
|
||||
return render_template('response.html', response = 'Task not found, bad URL')
|
||||
try:
|
||||
taskusers = TaskUser.query.filter_by(taskid = task_id).all()
|
||||
except:
|
||||
taskusers = None
|
||||
creatorid = task.creatorid
|
||||
if request.method == 'GET':
|
||||
if creatorid is None:
|
||||
try:
|
||||
db.session.delete(task)
|
||||
db.session.commit()
|
||||
if taskusers != None:
|
||||
db.session.delete(taskusers)
|
||||
db.session.commit()
|
||||
return render_template('response.html', response = 'Task deleted')
|
||||
except:
|
||||
return render_template('response.html', response = 'Deleting task failed')
|
||||
try:
|
||||
if taskusers != None:
|
||||
for taskuser in taskusers:
|
||||
db.session.delete(taskuser)
|
||||
db.session.commit()
|
||||
except:
|
||||
return render_template('response.html', response = 'Deleting user assignment to task failed')
|
||||
return render_template('response.html', response = 'Task deleted')
|
||||
else:
|
||||
return render_template('deltask.html', task = task)
|
||||
if request.method == 'POST':
|
||||
@ -165,6 +169,13 @@ def deltask(task_id:int):
|
||||
try:
|
||||
db.session.delete(task)
|
||||
db.session.commit()
|
||||
return render_template('response.html', response = 'Task deleted')
|
||||
except:
|
||||
return render_template('response.html', response = 'Deleting task failed')
|
||||
try:
|
||||
if taskusers != None:
|
||||
for taskuser in taskusers:
|
||||
db.session.delete(taskuser)
|
||||
db.session.commit()
|
||||
except:
|
||||
return render_template('response.html', response = 'Deleting user assignment to task failed')
|
||||
return render_template('response.html', response = 'Task deleted')
|
||||
|
@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="stylesheet" href="/static/style.css" />
|
||||
<title>{{response}}</title>
|
||||
<title>Task Manager</title>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
@ -17,7 +17,7 @@
|
||||
</header>
|
||||
<main class="container page page-project">
|
||||
<section >
|
||||
<h1>{{response}}</h1>
|
||||
<p>{{response}}<p>
|
||||
</section>
|
||||
</main>
|
||||
<footer>
|
||||
|
Loading…
Reference in New Issue
Block a user