Nice, upload button

This commit is contained in:
shamoon
2026-01-23 15:29:19 -08:00
parent 33c5d5bab0
commit 94c6108006
2 changed files with 21 additions and 3 deletions

View File

@@ -8,7 +8,7 @@
<link rel="stylesheet" href="{% static 'bootstrap.min.css' %}" /> <link rel="stylesheet" href="{% static 'bootstrap.min.css' %}" />
<link rel="stylesheet" href="{% static 'base.css' %}" /> <link rel="stylesheet" href="{% static 'base.css' %}" />
<style> <style>
:root { :root, .form-control {
color-scheme: light; color-scheme: light;
--bs-body-bg: #f5f5f5; --bs-body-bg: #f5f5f5;
--bs-body-color: #212529; --bs-body-color: #212529;
@@ -185,9 +185,14 @@
<div> <div>
<p class="text-uppercase text-muted mb-1 fw-semibold" style="letter-spacing: 0.08rem;">Step 1</p> <p class="text-uppercase text-muted mb-1 fw-semibold" style="letter-spacing: 0.08rem;">Step 1</p>
<h3 class="h5 mb-1">Export (v2)</h3> <h3 class="h5 mb-1">Export (v2)</h3>
<p class="small text-muted mb-0">Confirm the v2 export file is present before continuing.</p> <p class="small text-muted mb-0">Generate and upload the v2 export file. For larger files, place the file in the appropriate directory.</p>
</div> </div>
<div class="mt-auto"> <div class="mt-auto d-grid gap-2">
<form method="post" enctype="multipart/form-data" class="d-flex gap-2 align-items-center">
{% csrf_token %}
<input class="form-control form-control-sm" type="file" name="export_file" accept=".json" required>
<button class="btn btn-outline-secondary btn-sm" type="submit" name="action" value="upload">Upload</button>
</form>
<form method="post"> <form method="post">
{% csrf_token %} {% csrf_token %}
<button class="btn btn-primary w-100" type="submit" name="action" value="check">Re-check export</button> <button class="btn btn-primary w-100" type="submit" name="action" value="check">Re-check export</button>

View File

@@ -33,6 +33,19 @@ def migration_home(request):
elif action == "transform": elif action == "transform":
messages.info(request, "Starting transform… live output below.") messages.info(request, "Starting transform… live output below.")
request.session["start_transform_stream"] = True request.session["start_transform_stream"] = True
elif action == "upload":
upload = request.FILES.get("export_file")
if not upload:
messages.error(request, "No file selected.")
else:
try:
export_path.parent.mkdir(parents=True, exist_ok=True)
with export_path.open("wb") as dest:
for chunk in upload.chunks():
dest.write(chunk)
messages.success(request, f"Uploaded to {export_path}.")
except Exception as exc:
messages.error(request, f"Failed to save file: {exc}")
elif action == "import": elif action == "import":
messages.info( messages.info(
request, request,