Skip to content

Commit

Permalink
Added requested Changes from Reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
gitjannes committed Nov 12, 2024
1 parent 65d4fdb commit 86d4a87
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
3 changes: 2 additions & 1 deletion protzilla/run_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
14 changes: 14 additions & 0 deletions ui/runs/templates/runs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@

{% block content %}
<div class="container d-flex align-items-center justify-content-center" id="contain">
<div class="col" id="row">
{% if messages %}
<div class="messages">
{% for message in messages %}
<div class="alert alert-dismissible fade show ps-5{% if message.tags %} {{ message.tags }}{% endif %}"
role="alert">
{{ message | safe }}
<button type="button" class="btn-close" data-bs-dismiss="alert"
aria-label="Close"></button>
</div>
{% endfor %}
</div>
<br>
{% endif %}
<div class="row" id="row">
<div class="col mx-4">
<form action="{% url 'runs:create' %}" method="post">
Expand Down
14 changes: 13 additions & 1 deletion ui/runs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))

Expand Down

0 comments on commit 86d4a87

Please sign in to comment.