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