mobile menu added

This commit is contained in:
Joren de Graaf
2026-10-02 13:13:38 +02:00
parent 3b864f001d
commit ddcce61868
53 changed files with 780 additions and 18 deletions
+12 -1
View File
@@ -216,7 +216,7 @@ def _encode_audio_multipart(uploaded_file):
"""Build the multipart request expected by the classifier without a third-party HTTP client."""
boundary = f"----DjangoAudioUpload{uuid.uuid4().hex}"
filename = Path(uploaded_file.name).name.replace('"', "")
content_type = uploaded_file.content_type or mimetypes.guess_type(filename)[0] or "application/octet-stream"
content_type = getattr(uploaded_file, "content_type", None) or mimetypes.guess_type(filename)[0] or "application/octet-stream"
header = (
f"--{boundary}\r\n"
f'Content-Disposition: form-data; name="file"; filename="{filename}"\r\n'
@@ -346,11 +346,22 @@ def submit_manual_pending_event(request):
status=400,
)
uploaded_file = request.FILES.get("audio")
if uploaded_file:
if uploaded_file.size > MAX_AUDIO_SIZE or uploaded_file.content_type not in ("audio/wav", "audio/wave", "audio/x-wav"):
return render(request, "fireworks_detect/manual_pending_submission.html", {"error": _("Please attach a WAV clip no larger than 25 MiB.")}, status=400)
header = uploaded_file.read(12)
uploaded_file.seek(0)
if len(header) != 12 or header[:4] != b"RIFF" or header[8:] != b"WAVE":
return render(request, "fireworks_detect/manual_pending_submission.html", {"error": _("The attached audio is not a WAV file.")}, status=400)
uploaded_file.name = f"sound-signal-manual-{timezone.now():%Y%m%d-%H%M%S}-{uuid.uuid4().hex[:8]}.wav"
latitude, longitude = _manual_coordinates(request)
h3_cell = cell_from_coordinates(latitude, longitude)
direction_degrees, direction_accuracy_degrees = _manual_direction(request)
pending = PendingEvent.objects.create(
audio_file=uploaded_file,
original_filename="Manual fireworks report",
classifier_response={},
source_type=PendingEvent.SourceType.MANUAL,