From 86d4a87e520e71b5231761b96a7ec2a1de12671a Mon Sep 17 00:00:00 2001 From: gitjannes Date: Tue, 12 Nov 2024 15:04:01 +0100 Subject: [PATCH] Added requested Changes from Reviews --- protzilla/run_v2.py | 3 ++- ui/runs/templates/runs/index.html | 14 ++++++++++++++ ui/runs/views.py | 14 +++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/protzilla/run_v2.py b/protzilla/run_v2.py index f3b8bd9e..f0499ac0 100644 --- a/protzilla/run_v2.py +++ b/protzilla/run_v2.py @@ -22,11 +22,12 @@ def get_available_run_names() -> list[str]: ] def delete_run_folder(run_name) -> None: - path = os.path.join(paths.RUNS_PATH, "test") + path = os.path.join(paths.RUNS_PATH, run_name) if os.path.isdir(path): shutil.rmtree(path) + class Run: class ErrorHandlingContextManager: def __init__(self, run): diff --git a/ui/runs/templates/runs/index.html b/ui/runs/templates/runs/index.html index 6bdd8714..4da97d87 100644 --- a/ui/runs/templates/runs/index.html +++ b/ui/runs/templates/runs/index.html @@ -8,6 +8,20 @@ {% block content %}
+
+ {% if messages %} +
+ {% for message in messages %} + + {% endfor %} +
+
+ {% endif %}
diff --git a/ui/runs/views.py b/ui/runs/views.py index 770da36f..6bfc709a 100644 --- a/ui/runs/views.py +++ b/ui/runs/views.py @@ -245,7 +245,19 @@ def delete_(request: HttpRequest): if run_name in active_runs: del active_runs[run_name] - delete_run_folder(run_name) + try: + delete_run_folder(run_name) + except Exception as e: + display_message( + { + "level": 40, + "msg": f"Couldn't delete the run '{run_name}' . Please check the permissions for this file or try running Protzilla as administrator.", + "trace": format_trace(traceback.format_exception(e)), + }, + request, + ) + traceback.print_exc() + return HttpResponseRedirect(reverse("runs:index")) return HttpResponseRedirect(reverse("runs:index"))