forked from expo/troggle
return to correct wallet
This commit is contained in:
parent
8d9b320d89
commit
7fc058b1da
@ -79,21 +79,37 @@ def expofilerename(request, filepath):
|
||||
print(message)
|
||||
return render(request, "errors/generic.html", {"message": message})
|
||||
|
||||
|
||||
if request.method == "POST":
|
||||
form = ExpofileRenameForm(request.POST)
|
||||
if form.is_valid():
|
||||
if not form.is_valid():
|
||||
message = f'Invalid form response for file renaming "{request.POST}"'
|
||||
print(message)
|
||||
return render(request, "errors/generic.html", {"message": message})
|
||||
else:
|
||||
renameto = request.POST["renameto"]
|
||||
|
||||
if (folder / renameto).is_file():
|
||||
message = f'\n Cannot rename to an existing file. "{filename}" -> "{(folder / renameto)}"'
|
||||
if (folder / renameto).is_file() or (folder / renameto).is_dir():
|
||||
rename_bad = renameto
|
||||
message = f'\n Cannot rename to an existing file or folder. "{filename}" -> "{(folder / renameto)}"'
|
||||
print(message)
|
||||
return render(request, "errors/generic.html", {"message": message})
|
||||
return render(
|
||||
request,
|
||||
"renameform.html",
|
||||
{
|
||||
"form": form,
|
||||
"filepath": filepath,
|
||||
"filename": filename,
|
||||
"filesize": filesize,
|
||||
"rename_bad": rename_bad,
|
||||
},
|
||||
)
|
||||
else:
|
||||
actualpath.rename((folder / renameto))
|
||||
message = f'\n RENAMED "{filename}" -> "{(folder / renameto)}"'
|
||||
print(message)
|
||||
return redirect('/survey_scans/2023%252314/')
|
||||
walletid = actualpath.relative_to(Path(settings.SCANS_ROOT)).parent.stem.replace("#",":")
|
||||
print(walletid)
|
||||
return redirect(f'/survey_scans/{walletid}/')
|
||||
|
||||
else:
|
||||
form = ExpofileRenameForm()
|
||||
|
@ -4,14 +4,21 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h2>Rename "{{filename}}"</h2>
|
||||
<h2>Renaming "{{filename}}"</h2>
|
||||
<a href="/expofiles/{{filepath|urlencode}}">
|
||||
<figure class=onleft>
|
||||
<img src="/expofiles/{{filepath|urlencode}}" width=150px>
|
||||
<figcaption>filesize: {{filesize}} bytes
|
||||
</figcaption>
|
||||
</figure></a>
|
||||
{% if rename_bad %}
|
||||
<p style="font-family: monospace; font-weight: bold; color: red; font-size: 130%; text-align: center">
|
||||
|
||||
Cannot rename to '{{rename_bad}}' as a file (or a subfolder) of that name already exists here.
|
||||
</p>
|
||||
{% endif %}
|
||||
<div style = "max-width:95%; margin-left:8%; text-align: left; " >
|
||||
|
||||
<form method ='post' >
|
||||
{% csrf_token %}
|
||||
<br>
|
||||
|
Loading…
Reference in New Issue
Block a user