diff --git a/build-deb/taskmanager/DEBIAN/control b/build-deb/taskmanager/DEBIAN/control index 9d18c79..665aacc 100644 --- a/build-deb/taskmanager/DEBIAN/control +++ b/build-deb/taskmanager/DEBIAN/control @@ -8,4 +8,4 @@ Depends: gunicorn, python3-flask-sqlalchemy Homepage: https://gitea.dmz.rs/Decentrala/taskmanager Maintainer: Decentrala Description: Interactive TODO list Web app -Version: 1.0.9 +Version: 1.0.10 diff --git a/taskmanager/routes.py b/taskmanager/routes.py index 9cd227a..7711256 100644 --- a/taskmanager/routes.py +++ b/taskmanager/routes.py @@ -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 register.') + 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 register.') + 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 register.') + 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 register.') + 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') diff --git a/taskmanager/templates/response.html b/taskmanager/templates/response.html index 4dd8229..8244a19 100644 --- a/taskmanager/templates/response.html +++ b/taskmanager/templates/response.html @@ -4,7 +4,7 @@ - {{response}} + Task Manager
@@ -17,7 +17,7 @@
-

{{response}}

+

{{response}}