diff --git a/projects/tentacles/src/python/tentacles/blueprints/job_ui.py b/projects/tentacles/src/python/tentacles/blueprints/job_ui.py index 7e9bc4a..7d3c5fc 100644 --- a/projects/tentacles/src/python/tentacles/blueprints/job_ui.py +++ b/projects/tentacles/src/python/tentacles/blueprints/job_ui.py @@ -42,11 +42,17 @@ def manipulate_jobs(): flash("Could not duplicate", category="error") case "cancel": - ctx.db.cancel_job(uid=ctx.uid, jid=int(request.form.get("job_id"))) + ctx.db.cancel_job( + uid=None if ctx.is_admin else ctx.uid, + jid=int(request.form.get("job_id")), + ) flash("Cancellation reqested", category="info") case "delete": - ctx.db.delete_job(uid=ctx.uid, jid=int(request.form.get("job_id"))) + ctx.db.delete_job( + uid=None if ctx.is_admin else ctx.uid, + jid=int(request.form.get("job_id")), + ) flash("Job deleted", category="info") case _: diff --git a/projects/tentacles/src/python/tentacles/sql/files.sql b/projects/tentacles/src/python/tentacles/sql/files.sql index ec0c01d..ec10187 100644 --- a/projects/tentacles/src/python/tentacles/sql/files.sql +++ b/projects/tentacles/src/python/tentacles/sql/files.sql @@ -40,7 +40,7 @@ SELECT , (SELECT COUNT(*) FROM jobs WHERE file_id = f.id AND status_id < 0) AS `print_failures` FROM files f WHERE - user_id = :uid + (:uid IS NULL OR user_id = :uid) ; -- name: delete-file! @@ -67,7 +67,7 @@ SELECT * FROM files WHERE - user_id = :uid + (:uid IS NULL OR user_id = :uid) AND id = :fid ; diff --git a/projects/tentacles/src/python/tentacles/sql/jobs.sql b/projects/tentacles/src/python/tentacles/sql/jobs.sql index 777b7f6..748846e 100644 --- a/projects/tentacles/src/python/tentacles/sql/jobs.sql +++ b/projects/tentacles/src/python/tentacles/sql/jobs.sql @@ -183,7 +183,7 @@ UPDATE jobs SET cancelled_at = datetime('now') WHERE - user_id = :uid + (:uid IS NULL OR user_id = :uid) AND id = :jid ; @@ -208,7 +208,7 @@ WHERE -- name: delete-jobs-by-fid! DELETE FROM jobs WHERE - user_id = :uid + (:uid IS NULL OR user_id = :uid) AND file_id = :fid ; diff --git a/projects/tentacles/src/python/tentacles/templates/files_list.html.j2 b/projects/tentacles/src/python/tentacles/templates/files_list.html.j2 index 772728c..ef907d8 100644 --- a/projects/tentacles/src/python/tentacles/templates/files_list.html.j2 +++ b/projects/tentacles/src/python/tentacles/templates/files_list.html.j2 @@ -1,6 +1,6 @@ {% import "macros.html.j2" as macros %}