added translations

This commit is contained in:
Joren de Graaf
2026-10-01 22:43:45 +02:00
parent b676f35f0a
commit 13258e76c3
76 changed files with 1787 additions and 291 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+18 -17
View File
@@ -3,6 +3,7 @@ import json
from django.contrib import admin, messages
from django.utils import timezone
from django.utils.html import format_html
from django.utils.translation import gettext as _, gettext_lazy, ngettext
from .models import ClassificationRule, Event, PendingEvent, Sensor
@@ -22,11 +23,11 @@ class ClassificationAdmin(admin.ModelAdmin):
fields = ("audio_file", "sensor", "source_type", "occurrences", "location", "latitude", "longitude", "h3_cell", "direction_display", "direction_accuracy_degrees", "visually_confirmed", "original_filename", "created_at")
change_form_template = "admin/fireworks_detect/classification_audio_change_form.html"
@admin.display(description="Direction")
@admin.display(description=gettext_lazy("Direction"))
def direction_display(self, obj):
return obj.direction_display
@admin.display(description="Classifier response")
@admin.display(description=gettext_lazy("Classifier response"))
def pretty_classifier_response(self, obj):
return format_html("<pre>{}</pre>", json.dumps(obj.classifier_response, indent=2, sort_keys=True))
@@ -38,21 +39,21 @@ class PendingEventAdmin(ClassificationAdmin):
def has_add_permission(self, request):
return False
@admin.action(description="Approve selected samples and move them to Events")
@admin.action(description=gettext_lazy("Approve selected samples and move them to Events"))
def approve_selected(self, request, queryset):
approved = 0
for pending in queryset:
pending.approve()
approved += 1
self.message_user(request, f"{approved} sample(s) approved and moved to Events.", messages.SUCCESS)
self.message_user(request, ngettext("%(count)d sample approved and moved to Events.", "%(count)d samples approved and moved to Events.", approved) % {"count": approved}, messages.SUCCESS)
@admin.action(description="Deny selected samples and delete their uploaded audio")
@admin.action(description=gettext_lazy("Deny selected samples and delete their uploaded audio"))
def deny_selected(self, request, queryset):
denied = 0
for pending in queryset:
pending.deny()
denied += 1
self.message_user(request, f"{denied} sample(s) denied and removed.", messages.WARNING)
self.message_user(request, ngettext("%(count)d sample denied and removed.", "%(count)d samples denied and removed.", denied) % {"count": denied}, messages.WARNING)
@admin.register(Event)
@@ -72,30 +73,30 @@ class SensorAdmin(admin.ModelAdmin):
readonly_fields = ("token_prefix", "last_heartbeat", "last_submission", "created_at")
actions = ("issue_api_token",)
fieldsets = (
("Sensor", {"fields": ("name", "is_active", "created_at")}),
("API token", {"fields": ("token_prefix",), "description": "Save the sensor first, select it in the list, then choose ‘Issue or rotate API token’. The complete token is shown once only; its salted hash is the only value stored."}),
("Heartbeat", {"fields": ("last_heartbeat", "last_submission"), "description": "Devices should POST to /fireworks/heartbeat/ with Authorization: Bearer <token>. Green means seen within 5 minutes; amber within 15; red is older or never seen."}),
(gettext_lazy("Sensor"), {"fields": ("name", "is_active", "created_at")}),
(gettext_lazy("API token"), {"fields": ("token_prefix",), "description": gettext_lazy("Save the sensor first, select it in the list, then choose ‘Issue or rotate API token’. The complete token is shown once only; its salted hash is the only value stored.")}),
(gettext_lazy("Heartbeat"), {"fields": ("last_heartbeat", "last_submission"), "description": gettext_lazy("Devices should POST to /fireworks/heartbeat/ with Authorization: Bearer <token>. Green means seen within 5 minutes; amber within 15; red is older or never seen.")}),
)
@admin.display(description="Heartbeat")
@admin.display(description=gettext_lazy("Heartbeat"))
def heartbeat_light(self, obj):
if not obj.last_heartbeat:
colour, label = "#ef4444", "Never seen"
colour, label = "#ef4444", _("Never seen")
else:
age = timezone.now() - obj.last_heartbeat
if age.total_seconds() <= 300:
colour, label = "#22c55e", "Online"
colour, label = "#22c55e", _("Online")
elif age.total_seconds() <= 900:
colour, label = "#f59e0b", "Delayed"
colour, label = "#f59e0b", _("Delayed")
else:
colour, label = "#ef4444", "Offline"
colour, label = "#ef4444", _("Offline")
return format_html('<span style="display:inline-flex;align-items:center;gap:6px"><span style="width:10px;height:10px;border-radius:50%;background:{}"></span>{}</span>', colour, label)
@admin.action(description="Issue or rotate API token (shown once)")
@admin.action(description=gettext_lazy("Issue or rotate API token (shown once)"))
def issue_api_token(self, request, queryset):
if queryset.count() != 1:
self.message_user(request, "Select exactly one sensor to issue a token.", messages.ERROR)
self.message_user(request, _("Select exactly one sensor to issue a token."), messages.ERROR)
return
sensor = queryset.get()
token = sensor.issue_token()
self.message_user(request, format_html('Copy this token now; it is not stored and will not be shown again: <code>{}</code>', token), messages.WARNING)
self.message_user(request, format_html(_("Copy this token now; it is not stored and will not be shown again: <code>{}</code>"), token), messages.WARNING)
+13 -12
View File
@@ -6,12 +6,13 @@ from django.core.exceptions import ValidationError
from django.core.files.storage import default_storage
from django.db import models, transaction
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
class Sensor(models.Model):
"""A physical recorder authorised to submit audio to the device API."""
name = models.CharField(max_length=100, unique=True, help_text="A recognisable device name, e.g. Garden ESP32.")
name = models.CharField(max_length=100, unique=True, help_text=_("A recognisable device name, e.g. Garden ESP32."))
is_active = models.BooleanField(default=True)
token_prefix = models.CharField(max_length=15, blank=True, editable=False)
token_hash = models.CharField(max_length=256, blank=True, editable=False)
@@ -50,8 +51,8 @@ class ClassificationRule(models.Model):
"""A configurable inclusion or exclusion rule for a classification label."""
class RuleType(models.TextChoices):
WHITELIST = "whitelist", "Whitelist"
BLACKLIST = "blacklist", "Blacklist"
WHITELIST = "whitelist", _("Whitelist")
BLACKLIST = "blacklist", _("Blacklist")
value = models.CharField(max_length=255)
rule_type = models.CharField(max_length=10, choices=RuleType.choices)
@@ -71,8 +72,8 @@ class ClassifiedAudio(models.Model):
"""Shared fields for a classifier response and its original audio upload."""
class SourceType(models.TextChoices):
SENSOR = "sensor", "Sensor"
MANUAL = "manual", "Manual report"
SENSOR = "sensor", _("Sensor")
MANUAL = "manual", _("Manual report")
audio_file = models.FileField(upload_to="fireworks_audio/%Y/%m/%d", blank=True)
sensor = models.ForeignKey(Sensor, null=True, blank=True, on_delete=models.SET_NULL, related_name="%(class)s_records")
@@ -103,11 +104,11 @@ class ClassifiedAudio(models.Model):
if self.direction_degrees is not None and (
not math.isfinite(self.direction_degrees) or not 0 <= self.direction_degrees < 360
):
errors["direction_degrees"] = "Direction must be a finite value from 0 up to, but not including, 360 degrees."
errors["direction_degrees"] = _("Direction must be a finite value from 0 up to, but not including, 360 degrees.")
if self.direction_accuracy_degrees is not None and (
not math.isfinite(self.direction_accuracy_degrees) or self.direction_accuracy_degrees < 0
):
errors["direction_accuracy_degrees"] = "Compass accuracy must be a finite, non-negative value."
errors["direction_accuracy_degrees"] = _("Compass accuracy must be a finite, non-negative value.")
if errors:
raise ValidationError(errors)
@@ -138,7 +139,7 @@ class ClassifiedAudio(models.Model):
@property
def primary_label(self):
return self.primary_prediction.get("class", "No prediction")
return self.primary_prediction.get("class", _("No prediction"))
@property
def primary_score(self):
@@ -177,8 +178,8 @@ class PendingEvent(ClassifiedAudio):
"""A submitted classification awaiting a human review in Django admin."""
class Meta(ClassifiedAudio.Meta):
verbose_name = "Pending event"
verbose_name_plural = "Pending"
verbose_name = _("Pending event")
verbose_name_plural = _("Pending")
@transaction.atomic
def approve(self):
@@ -214,5 +215,5 @@ class Event(ClassifiedAudio):
approved_at = models.DateTimeField(auto_now_add=True)
class Meta(ClassifiedAudio.Meta):
verbose_name = "Event"
verbose_name_plural = "Events"
verbose_name = _("Event")
verbose_name_plural = _("Events")
@@ -1,32 +1,33 @@
{% load i18n %}
{% if error %}
<section class="results-card error-card" role="alert">
<h2>Analysis unavailable</h2>
<h2>{% trans "Analysis unavailable" %}</h2>
<p>{{ error }}</p>
</section>
{% else %}
<section class="results-card" tabindex="-1">
<div class="result-heading">
<div>
<h2>Analysis complete</h2>
<h2>{% trans "Analysis complete" %}</h2>
<p>{{ result.filename|default:"Audio file" }}</p>
</div>
<span class="result-status">Ready</span>
<span class="result-status">{% trans "Ready" %}</span>
</div>
<div class="meta">
<span>{{ result.duration_seconds|default:"—" }} seconds</span>
<span>{{ result.frames_analysed|default:"—" }} frames analysed</span>
<span>{{ result.yamnet_sample_rate|default:"—" }} Hz model rate</span>
<span>{% blocktrans with duration=result.duration_seconds|default:"—" %}{{ duration }} seconds{% endblocktrans %}</span>
<span>{% blocktrans with frames=result.frames_analysed|default:"—" %}{{ frames }} frames analysed{% endblocktrans %}</span>
<span>{% blocktrans with rate=result.yamnet_sample_rate|default:"—" %}{{ rate }} Hz model rate{% endblocktrans %}</span>
</div>
<div class="legend" aria-label="Result legend">
{% if firework_count %}<span class="firework">✦ {{ firework_count }} firework-related signal{{ firework_count|pluralize }}</span>{% endif %}
{% if speech_count %}<span class="speech">● {{ speech_count }} speech/privacy signal{{ speech_count|pluralize }}</span>{% endif %}
<div class="legend" aria-label="{% trans "Result legend" %}">
{% if firework_count %}<span class="firework">✦ {% blocktrans count count=firework_count %}{{ count }} firework-related signal{% plural %}{{ count }} firework-related signals{% endblocktrans %}</span>{% endif %}
{% if speech_count %}<span class="speech">● {% blocktrans count count=speech_count %}{{ count }} speech/privacy signal{% plural %}{{ count }} speech/privacy signals{% endblocktrans %}</span>{% endif %}
</div>
<div class="result-grid">
<section class="result-group" aria-labelledby="top-predictions">
<h3 id="top-predictions">Top sound classes</h3>
<h3 id="top-predictions">{% trans "Top sound classes" %}</h3>
{% if predictions %}
<ul class="prediction-list">
{% for prediction in predictions %}
@@ -37,11 +38,11 @@
</li>
{% endfor %}
</ul>
{% else %}<p class="empty">No overall predictions were returned.</p>{% endif %}
{% else %}<p class="empty">{% trans "No overall predictions were returned." %}</p>{% endif %}
</section>
<section class="result-group" aria-labelledby="peak-predictions">
<h3 id="peak-predictions">Notable moments</h3>
<h3 id="peak-predictions">{% trans "Notable moments" %}</h3>
{% if peak_predictions %}
<div class="peak-list">
{% for prediction in peak_predictions %}
@@ -55,14 +56,14 @@
</article>
{% endfor %}
</div>
{% else %}<p class="empty">No peak events were returned.</p>{% endif %}
{% else %}<p class="empty">{% trans "No peak events were returned." %}</p>{% endif %}
</section>
</div>
{% if submission_token %}
<div class="review-submission" id="review-submission">
<input type="hidden" name="classification_token" value="{{ submission_token }}">
<div><strong>Submit this sample for review</strong><p>The audio and signed classifier response will be added to Pending.</p></div>
<button type="button" hx-post="{% url 'fireworks_detect:submit_pending' %}" hx-target="#review-submission" hx-swap="outerHTML" hx-encoding="multipart/form-data">Send to Pending →</button>
<div><strong>{% trans "Submit this sample for review" %}</strong><p>{% trans "The audio and signed classifier response will be added to Pending." %}</p></div>
<button type="button" hx-post="{% url 'fireworks_detect:submit_pending' %}" hx-target="#review-submission" hx-swap="outerHTML" hx-encoding="multipart/form-data">{% trans "Send to Pending →" %}</button>
</div>
{% endif %}
</section>
@@ -1,26 +1,27 @@
{% load vite %}
{% load i18n vite %}
<!doctype html>
<html lang="en" data-theme="dark">
<html lang="{{ request.LANGUAGE_CODE|default:'en' }}" data-theme="dark">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Report fireworks · Sound Signal</title>
<title>{% trans "Report fireworks · Sound Signal" %}</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css">
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.4/dist/htmx.min.js"></script>
{% vite_asset "frontend/src/entries/dashboard.js" %}
{% include "js_translations.html" %}
</head>
<body class="dashboard-page">
{% if user.is_authenticated %}<a class="profile-circle" href="{% url "user_settings" %}" aria-label="Open settings for {{ user.get_username }}" title="Settings">{{ user.get_username|first|upper }}</a>{% endif %}
{% if user.is_authenticated %}<a class="profile-circle" href="{% url "user_settings" %}" aria-label="{% blocktrans with username=user.get_username %}Open settings for {{ username }}{% endblocktrans %}" title="{% trans "Settings" %}">{{ user.get_username|first|upper }}</a>{% endif %}
<main class="dashboard-shell">
{% include "fireworks_detect/includes/navigation.html" %}
<section class="dashboard-intro" aria-labelledby="dashboard-title">
<p class="dashboard-kicker">Community reporting</p>
<h1 id="dashboard-title">Report what you heard.</h1>
<p>Quickly log fireworks when they happen. Your optional location is represented as an H3 cell on the map, rather than as precise coordinates.</p>
<p class="dashboard-kicker">{% trans "Community reporting" %}</p>
<h1 id="dashboard-title">{% trans "Report what you heard." %}</h1>
<p>{% trans "Quickly log fireworks when they happen. Your optional location is represented as an H3 cell on the map, rather than as precise coordinates." %}</p>
</section>
<section class="dashboard-section" aria-label="Quick fireworks report">
<section class="dashboard-section" aria-label="{% trans "Quick fireworks report" %}">
<div class="dashboard-report">
{% include "fireworks_detect/includes/manual_report_form.html" %}
</div>
@@ -28,15 +29,15 @@
<section class="dashboard-section dashboard-map" aria-labelledby="dashboard-map-title">
<header class="dashboard-section__header">
<div><p class="dashboard-kicker">Recent reports</p><h2 id="dashboard-map-title">Activity map</h2></div>
<a class="dashboard-link" href="{% url "fireworks_detect:map" %}">Open map controls <span aria-hidden="true">→</span></a>
<div><p class="dashboard-kicker">{% trans "Recent reports" %}</p><h2 id="dashboard-map-title">{% trans "Activity map" %}</h2></div>
<a class="dashboard-link" href="{% url "fireworks_detect:map" %}">{% trans "Open map controls" %} <span aria-hidden="true">→</span></a>
</header>
{% include "fireworks_detect/includes/map_panel.html" %}
</section>
<section class="dashboard-section" aria-labelledby="dashboard-audio-title">
<header class="dashboard-section__header">
<div><p class="dashboard-kicker">Audio analysis</p><h2 id="dashboard-audio-title">Classify a recording</h2></div>
<div><p class="dashboard-kicker">{% trans "Audio analysis" %}</p><h2 id="dashboard-audio-title">{% trans "Classify a recording" %}</h2></div>
</header>
<div class="upload-card dashboard-upload">
{% include "fireworks_detect/includes/audio_upload_form.html" %}
@@ -1,27 +1,28 @@
{% load i18n %}
{% if event.source_type == "manual" %}
<h2>Manual fireworks report</h2>
<p class="meta">Approved {{ event.approved_at|date:"j M Y, H:i" }} · Reported manually</p>
<h3>Report details</h3>
<div class="prediction prediction--firework"><strong>Occurrences</strong><span>{{ event.occurrences }}</span></div>
<div class="prediction prediction--firework"><strong>Location</strong><span>{{ event.location|default:"Not recorded" }}</span></div>
<div class="prediction prediction--firework"><strong>Captured location</strong><span>{{ event_h3_cell|default:"Not recorded" }}</span></div>
<div class="prediction prediction--firework"><strong>Direction</strong><span>{{ event.direction_display }}</span></div>
{% if event.direction_accuracy_degrees is not None %}<div class="prediction prediction--firework"><strong>Compass accuracy</strong><span>±{{ event.direction_accuracy_degrees|floatformat:"-1" }}°</span></div>{% endif %}
<div class="prediction prediction--firework"><strong>Visually confirmed</strong><span>{% if event.visually_confirmed %}Yes{% else %}No{% endif %}</span></div>
<p class="empty">This was a manual report; there is no audio classification attached.</p>
<h2>{% trans "Manual fireworks report" %}</h2>
<p class="meta">{% blocktrans with date=event.approved_at|date:"j M Y, H:i" %}Approved {{ date }} · Reported manually{% endblocktrans %}</p>
<h3>{% trans "Report details" %}</h3>
<div class="prediction prediction--firework"><strong>{% trans "Occurrences" %}</strong><span>{{ event.occurrences }}</span></div>
<div class="prediction prediction--firework"><strong>{% trans "Location" %}</strong><span>{{ event.location|default:"Not recorded" }}</span></div>
<div class="prediction prediction--firework"><strong>{% trans "Captured location" %}</strong><span>{{ event_h3_cell|default:"Not recorded" }}</span></div>
<div class="prediction prediction--firework"><strong>{% trans "Direction" %}</strong><span>{{ event.direction_display }}</span></div>
{% if event.direction_accuracy_degrees is not None %}<div class="prediction prediction--firework"><strong>{% trans "Compass accuracy" %}</strong><span>±{{ event.direction_accuracy_degrees|floatformat:"-1" }}°</span></div>{% endif %}
<div class="prediction prediction--firework"><strong>{% trans "Visually confirmed" %}</strong><span>{% if event.visually_confirmed %}{% trans "Yes" %}{% else %}{% trans "No" %}{% endif %}</span></div>
<p class="empty">{% trans "This was a manual report; there is no audio classification attached." %}</p>
{% else %}
<h2>{{ event.original_filename }}</h2>
<p class="meta">Approved {{ event.approved_at|date:"j M Y, H:i" }} · {{ result.duration_seconds|default:"—" }} seconds · {{ result.frames_analysed|default:"—" }} frames</p>
<h3>Top sound classes</h3>
<p class="meta">{% blocktrans with date=event.approved_at|date:"j M Y, H:i" duration=result.duration_seconds|default:"—" frames=result.frames_analysed|default:"—" %}Approved {{ date }} · {{ duration }} seconds · {{ frames }} frames{% endblocktrans %}</p>
<h3>{% trans "Top sound classes" %}</h3>
{% for prediction in predictions %}
<div class="prediction prediction--{{ prediction.kind }}"><strong>{{ prediction.label }}</strong><span>{{ prediction.score_display }}</span></div>
{% empty %}
<p class="empty">No predictions returned.</p>
<p class="empty">{% trans "No predictions returned." %}</p>
{% endfor %}
<h3>Notable moments</h3>
<h3>{% trans "Notable moments" %}</h3>
{% for prediction in peak_predictions %}
<div class="prediction prediction--{{ prediction.kind }}"><strong>{{ prediction.label }}</strong><span>{{ prediction.time_seconds|default:"—" }}s · {{ prediction.score_display }}</span></div>
{% empty %}
<p class="empty">No peak events returned.</p>
<p class="empty">{% trans "No peak events returned." %}</p>
{% endfor %}
{% endif %}
@@ -1,2 +1,2 @@
{% load vite %}
<!doctype html><html lang="en" data-theme="dark"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Events · Sound Signal</title><script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.4/dist/htmx.min.js"></script>{% vite_asset "frontend/src/entries/events.js" %}</head><body><main class="shell">{% include "fireworks_detect/includes/navigation.html" with active_page="events" %}<p class="eyebrow">Reviewed signal archive</p><h1>Approved events.</h1><p class="lede">This feed refreshes automatically every three seconds after a pending sample is approved in admin.</p><div class="grid"><section class="panel"><h2>Latest events</h2><div id="events-feed" hx-get="{% url 'fireworks_detect:events_list' %}" hx-trigger="load, every 3s" hx-swap="innerHTML"><p class="empty">Loading events…</p></div></section><section class="panel detail" id="event-detail"><h2>Select an event</h2><p class="empty">Choose an approved event to inspect its classification details.</p></section></div></main></body></html>
{% load i18n vite %}
<!doctype html><html lang="{{ request.LANGUAGE_CODE|default:'en' }}" data-theme="dark"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>{% trans "Events · Sound Signal" %}</title><script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.4/dist/htmx.min.js"></script>{% vite_asset "frontend/src/entries/events.js" %}{% include "js_translations.html" %}</head><body><main class="shell">{% include "fireworks_detect/includes/navigation.html" with active_page="events" %}<p class="eyebrow">{% trans "Reviewed signal archive" %}</p><h1>{% trans "Approved events." %}</h1><p class="lede">{% trans "This feed refreshes automatically every three seconds after a pending sample is approved in admin." %}</p><div class="grid"><section class="panel"><h2>{% trans "Latest events" %}</h2><div id="events-feed" hx-get="{% url 'fireworks_detect:events_list' %}" hx-trigger="load, every 3s" hx-swap="innerHTML"><p class="empty">{% trans "Loading events…" %}</p></div></section><section class="panel detail" id="event-detail"><h2>{% trans "Select an event" %}</h2><p class="empty">{% trans "Choose an approved event to inspect its classification details." %}</p></section></div></main></body></html>
@@ -1,20 +1,21 @@
{% load i18n %}
{% if events %}
{% for event in events %}
<button class="event {% if event.source_type == "manual" %}event--manual{% else %}event--sensor{% endif %}" hx-get="{% url 'fireworks_detect:event_detail' event.id %}" hx-target="#event-detail" hx-swap="innerHTML">
<span class="event__content">
{% if event.source_type == "manual" %}
<span class="event__source">Manual report</span>
<strong>Manual fireworks report</strong><br>
<small>{{ event.occurrences }} occurrence{{ event.occurrences|pluralize }}{% if event.location %} · {{ event.location }}{% endif %}</small>
<span class="event__source">{% trans "Manual report" %}</span>
<strong>{% trans "Manual fireworks report" %}</strong><br>
<small>{% blocktrans count count=event.occurrences %}{{ count }} occurrence{% plural %}{{ count }} occurrences{% endblocktrans %}{% if event.location %} · {{ event.location }}{% endif %}</small>
{% else %}
<span class="event__source">Sensor classification</span>
<span class="event__source">{% trans "Sensor classification" %}</span>
<strong>{{ event.primary_label }}</strong><br>
<small>{{ event.original_filename }} · {{ event.duration }}s</small>
{% endif %}
</span>
<span class="badge">{% if event.source_type == "manual" %}Manual →{% else %}{{ event.primary_score }} →{% endif %}</span>
<span class="badge">{% if event.source_type == "manual" %}{% trans "Manual" %} →{% else %}{{ event.primary_score }} →{% endif %}</span>
</button>
{% endfor %}
{% else %}
<p class="empty">No approved events yet. Submit a classification, then approve it from the Pending page in admin.</p>
<p class="empty">{% trans "No approved events yet. Submit a classification, then approve it from the Pending page in admin." %}</p>
{% endif %}
@@ -1,13 +1,14 @@
{% load vite %}
{% load i18n vite %}
<!DOCTYPE html>
<html lang="en" data-theme="dark">
<html lang="{{ request.LANGUAGE_CODE|default:'en' }}" data-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sound Signal · Fireworks detection</title>
<title>{% trans "Sound Signal · Fireworks detection" %}</title>
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.4/dist/htmx.min.js"></script>
{% vite_asset "frontend/src/entries/fireworks-home.js" %}
{% include "js_translations.html" %}
</head>
<body>
@@ -16,16 +17,14 @@
<section class="intro" aria-labelledby="page-title">
<p class="kicker">Audio event analysis</p>
<h1 id="page-title">See what your audio heard.</h1>
<p class="lede">Drop a recording to identify its most likely sounds. Firework-related signals are
highlighted in amber; speech-related signals are marked in red for future privacy filtering.</p>
<a href="https://pixabay.com/sound-effects/search/fireworks/" class="button" target="_blank">Here's some
samples to test with</a>
<p class="kicker">{% trans "Audio event analysis" %}</p>
<h1 id="page-title">{% trans "See what your audio heard." %}</h1>
<p class="lede">{% blocktrans trimmed %}Drop a recording to identify its most likely sounds. Firework-related signals are highlighted in amber; speech-related signals are marked in red for future privacy filtering.{% endblocktrans %}</p>
<a href="https://pixabay.com/sound-effects/search/fireworks/" class="button" target="_blank">{% trans "Here are some samples to test with" %}</a>
<br /><br />
</section>
<section class="upload-card" aria-label="Upload audio for classification">
<section class="upload-card" aria-label="{% trans "Upload audio for classification" %}">
{% include "fireworks_detect/includes/audio_upload_form.html" %}
</section>
</main>
@@ -1,18 +1,19 @@
{% load i18n %}
<form class="upload-form" action="{% url "fireworks_detect:classify_upload" %}" method="post" enctype="multipart/form-data" hx-post="{% url "fireworks_detect:classify_upload" %}" hx-target="#classification-results" hx-swap="innerHTML" hx-encoding="multipart/form-data" hx-indicator="#upload-indicator">
{% csrf_token %}
<label class="drop-zone" id="drop-zone">
<input class="file-input" id="audio-file" type="file" name="audio" accept="audio/*,.wav,.mp3,.m4a,.ogg,.flac,.aac,.opus" required>
<span>
<span class="upload-icon">↑</span>
<strong>Drop an audio file here</strong>
<span>or click to browse your device</span>
<strong>{% trans "Drop an audio file here" %}</strong>
<span>{% trans "or click to browse your device" %}</span>
</span>
<span class="file-name" id="file-name">No file selected</span>
<span class="file-name" id="file-name">{% trans "No file selected" %}</span>
</label>
<div class="form-footer">
<p class="file-note">WAV, MP3, M4A, OGG and more · 25 MiB maximum</p>
<button type="submit"><span class="spinner htmx-indicator" id="upload-indicator" aria-hidden="true"></span>Analyse audio</button>
<p class="file-note">{% trans "WAV, MP3, M4A, OGG and more · 25 MiB maximum" %}</p>
<button type="submit"><span class="spinner htmx-indicator" id="upload-indicator" aria-hidden="true"></span>{% trans "Analyse audio" %}</button>
</div>
<section id="classification-results" aria-live="polite" aria-label="Classification results"></section>
<section id="classification-results" aria-live="polite" aria-label="{% trans "Classification results" %}"></section>
</form>
<p id="upload-status" role="status" aria-live="polite"></p>
@@ -1,22 +1,23 @@
{% load i18n %}
<section class="manual-report" aria-labelledby="manual-report-title">
<p class="eyebrow">No recording needed</p>
<h2 class="manual-report__title" id="manual-report-title">Report fireworks now</h2>
<p class="manual-report__intro">Choose how many times you heard fireworks, then send it straight to Pending. The report is timestamped now.</p>
<p class="eyebrow">{% trans "No recording needed" %}</p>
<h2 class="manual-report__title" id="manual-report-title">{% trans "Report fireworks now" %}</h2>
<p class="manual-report__intro">{% trans "Choose how many times you heard fireworks, then send it straight to Pending. The report is timestamped now." %}</p>
<form id="manual-report-form" action="{% url "fireworks_detect:submit_manual_pending" %}" method="post" hx-post="{% url "fireworks_detect:submit_manual_pending" %}" hx-target="#manual-submission" hx-swap="outerHTML">
{% csrf_token %}
<label class="manual-report__label" for="manual-occurrences">Number of occurrences</label>
<label class="manual-report__label" for="manual-occurrences">{% trans "Number of occurrences" %}</label>
<input id="manual-latitude" name="latitude" type="hidden">
<input id="manual-longitude" name="longitude" type="hidden">
<input id="manual-direction-degrees" name="direction_degrees" type="hidden">
<input id="manual-direction-accuracy" name="direction_accuracy_degrees" type="hidden">
<input id="manual-occurrences" name="occurrences" type="number" min="1" max="1000" value="1" required inputmode="numeric">
<div class="manual-direction-panel" id="manual-direction-panel" hidden>
<strong class="manual-direction-panel__heading">Direction <span>(optional)</span></strong>
<p class="manual-direction-panel__copy">Point the top of your phone toward the fireworks, then capture a single compass reading.</p>
<button id="manual-capture-direction" class="manual-direction-panel__button" type="button">Capture direction</button>
<strong class="manual-direction-panel__heading">{% trans "Direction" %} <span>({% trans "optional" %})</span></strong>
<p class="manual-direction-panel__copy">{% trans "Point the top of your phone toward the fireworks, then capture a single compass reading." %}</p>
<button id="manual-capture-direction" class="manual-direction-panel__button" type="button">{% trans "Capture direction" %}</button>
<div id="manual-direction-status" class="manual-direction-panel__status" aria-live="polite"></div>
</div>
<button id="manual-submit" class="manual-report__submit" type="button">I heard fireworks — send to Pending</button>
<button id="manual-submit" class="manual-report__submit" type="button">{% trans "I heard fireworks — send to Pending" %}</button>
</form>
<div id="manual-submission" class="manual-report__submission" aria-live="polite"></div>
</section>
@@ -1,7 +1,8 @@
<section class="map-panel" aria-label="Manual fireworks report map">
<div class="map-header"><strong>Manual reports · privacy-preserving H3 cells</strong><span class="live"><i></i> H3 resolution {{ h3_resolution }} · sensor layer disabled</span></div>
<div class="map-wrap"><div id="event-map" class="map" data-h3-resolution="{{ h3_resolution }}" aria-label="Interactive map of manual fireworks reports"></div>
<aside class="legend" aria-label="Map legend"><h2>Manual reports</h2><div><span class="legend-dot"></span> Report marker at H3-cell centre</div><div><span class="legend-ring"></span> H3 cell (resolution {{ h3_resolution }})</div><div><span class="legend-line"></span> Saved compass direction</div></aside>
{% load i18n %}
<section class="map-panel" aria-label="{% trans "Manual fireworks report map" %}">
<div class="map-header"><strong>{% trans "Manual reports · privacy-preserving H3 cells" %}</strong><span class="live"><i></i> {% blocktrans with resolution=h3_resolution %}H3 resolution {{ resolution }} · sensor layer disabled{% endblocktrans %}</span></div>
<div class="map-wrap"><div id="event-map" class="map" data-h3-resolution="{{ h3_resolution }}" aria-label="{% trans "Interactive map of manual fireworks reports" %}"></div>
<aside class="legend" aria-label="{% trans "Map legend" %}"><h2>{% trans "Manual reports" %}</h2><div><span class="legend-dot"></span> {% trans "Report marker at H3-cell centre" %}</div><div><span class="legend-ring"></span> {% blocktrans with resolution=h3_resolution %}H3 cell (resolution {{ resolution }}){% endblocktrans %}</div><div><span class="legend-line"></span> {% trans "Saved compass direction" %}</div></aside>
</div>
</section>
{{ h3_cells|json_script:"h3-cells-data" }}
@@ -1,11 +1,24 @@
{% load i18n %}
<header class="fireworks-header">
<a class="fireworks-brand" href="{% url "fireworks_detect:fireworks" %}"><span class="brand-mark">✦</span> Sound Signal</a>
<div class="fireworks-header__controls">
<nav class="fireworks-nav" aria-label="Fireworks navigation">
<a href="{% url "fireworks_detect:fireworks" %}"{% if active_page == "analyse" %} aria-current="page"{% endif %}>Analyse</a>
<a href="{% url "fireworks_detect:map" %}"{% if active_page == "map" %} aria-current="page"{% endif %}>Map</a>
<a href="{% url "fireworks_detect:events" %}"{% if active_page == "events" %} aria-current="page"{% endif %}>Events</a>
<nav class="fireworks-nav" aria-label="{% trans "Fireworks navigation" %}">
<a href="{% url "fireworks_detect:fireworks" %}"{% if active_page == "analyse" %} aria-current="page"{% endif %}>{% trans "Analyse" %}</a>
<a href="{% url "fireworks_detect:map" %}"{% if active_page == "map" %} aria-current="page"{% endif %}>{% trans "Map" %}</a>
<a href="{% url "fireworks_detect:events" %}"{% if active_page == "events" %} aria-current="page"{% endif %}>{% trans "Events" %}</a>
</nav>
<button class="theme-toggle theme-toggle--inline" type="button" aria-label="Switch theme"></button>
{% if not request.user.is_authenticated %}
<form class="public-language" action="{% url 'set_anonymous_language' %}" method="post" style="display:flex;align-items:center;gap:.3rem;color:var(--muted,#aab9d8);font-size:.78rem">
{% csrf_token %}
<input type="hidden" name="next" value="{{ request.get_full_path }}">
<label for="public-language-choice">{% trans "Language" %}</label>
<select id="public-language-choice" name="language" style="border:1px solid var(--line,#2b3d68);border-radius:.5rem;padding:.4rem;color:inherit;background:transparent;font:inherit">
<option value="nl"{% if request.LANGUAGE_CODE == 'nl' %} selected{% endif %}>Nederlands</option>
<option value="en"{% if request.LANGUAGE_CODE == 'en' %} selected{% endif %}>English</option>
</select>
<button type="submit" style="border:1px solid var(--line,#2b3d68);border-radius:.5rem;padding:.4rem;color:inherit;background:transparent;font:inherit;cursor:pointer">OK</button>
</form>
{% endif %}
<button class="theme-toggle theme-toggle--inline" type="button" aria-label="{% trans "Switch theme" %}"></button>
</div>
</header>
@@ -1,7 +1,8 @@
{% load i18n %}
<div id="manual-submission" role="status">
{% if error %}
<strong>Could not report fireworks</strong><p>{{ error }}</p>
<strong>{% trans "Could not report fireworks" %}</strong><p>{{ error }}</p>
{% else %}
<strong>Report sent to Pending</strong><p>{{ pending.occurrences }} occurrence{{ pending.occurrences|pluralize }} reported at {{ pending.created_at|date:"H:i" }}.</p>
<strong>{% trans "Report sent to Pending" %}</strong><p>{% blocktrans count count=pending.occurrences with time=pending.created_at|date:"H:i" %}{{ count }} occurrence reported at {{ time }}.{% plural %}{{ count }} occurrences reported at {{ time }}.{% endblocktrans %}</p>
{% endif %}
</div>
@@ -1,30 +1,31 @@
{% load vite %}
{% load i18n vite %}
<!DOCTYPE html>
<html lang="en" data-theme="dark">
<html lang="{{ request.LANGUAGE_CODE|default:'en' }}" data-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Signal map · Sound Signal</title>
<title>{% trans "Signal map · Sound Signal" %}</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css">
{% vite_asset "frontend/src/entries/map.js" %}
{% include "js_translations.html" %}
</head>
<body>
<main class="shell">
{% include "fireworks_detect/includes/navigation.html" with active_page="map" %}
<section class="headline" aria-labelledby="map-title">
<div><p class="kicker">Manual report intelligence</p><h1 id="map-title">Sound activity map.</h1></div>
<p>Reviewed manual reports with a captured location appear as their H3 cell, not their precise coordinates. Saved phone compass readings show the reported direction of the sound.</p>
<div><p class="kicker">{% trans "Manual report intelligence" %}</p><h1 id="map-title">{% trans "Sound activity map." %}</h1></div>
<p>{% trans "Reviewed manual reports with a captured location appear as their H3 cell, not their precise coordinates. Saved phone compass readings show the reported direction of the sound." %}</p>
</section>
<form class="filters" method="get" action="{% url 'fireworks_detect:map' %}" aria-label="Map filters">
<div class="filter"><label for="event-source">Source</label><select id="event-source" disabled><option selected>Manual reports</option><option>Sensor events — coming soon</option></select></div>
<div class="filter"><label for="range">Period</label><select id="range" name="range"><option value="7" {% if map_filters.range == "7" %}selected{% endif %}>Last 7 days</option><option value="14" {% if map_filters.range == "14" %}selected{% endif %}>Last 2 weeks</option><option value="30" {% if map_filters.range == "30" %}selected{% endif %}>Last 30 days</option><option value="all" {% if map_filters.range == "all" %}selected{% endif %}>All time</option><option value="custom" {% if map_filters.range == "custom" %}selected{% endif %}>Custom range</option></select></div>
<div class="filter"><label for="from-date">From</label><input id="from-date" name="from" type="date" value="{{ map_filters.date_from }}"></div>
<div class="filter"><label for="to-date">To</label><input id="to-date" name="to" type="date" value="{{ map_filters.date_to }}"></div>
<div class="filter"><label for="visual">Visual confirmation</label><select id="visual" name="visual"><option value="all" {% if map_filters.visual == "all" %}selected{% endif %}>Any report</option><option value="yes" {% if map_filters.visual == "yes" %}selected{% endif %}>Visually confirmed</option><option value="no" {% if map_filters.visual == "no" %}selected{% endif %}>Not visually confirmed</option></select></div>
<button class="filter-submit" type="submit">Apply filters</button>
<span class="map-tag">{{ mapped_event_count }} report{{ mapped_event_count|pluralize }}</span>
<form class="filters" method="get" action="{% url 'fireworks_detect:map' %}" aria-label="{% trans "Map filters" %}">
<div class="filter"><label for="event-source">{% trans "Source" %}</label><select id="event-source" disabled><option selected>{% trans "Manual reports" %}</option><option>{% trans "Sensor events — coming soon" %}</option></select></div>
<div class="filter"><label for="range">{% trans "Period" %}</label><select id="range" name="range"><option value="7" {% if map_filters.range == "7" %}selected{% endif %}>{% trans "Last 7 days" %}</option><option value="14" {% if map_filters.range == "14" %}selected{% endif %}>{% trans "Last 2 weeks" %}</option><option value="30" {% if map_filters.range == "30" %}selected{% endif %}>{% trans "Last 30 days" %}</option><option value="all" {% if map_filters.range == "all" %}selected{% endif %}>{% trans "All time" %}</option><option value="custom" {% if map_filters.range == "custom" %}selected{% endif %}>{% trans "Custom range" %}</option></select></div>
<div class="filter"><label for="from-date">{% trans "From" %}</label><input id="from-date" name="from" type="date" value="{{ map_filters.date_from }}"></div>
<div class="filter"><label for="to-date">{% trans "To" %}</label><input id="to-date" name="to" type="date" value="{{ map_filters.date_to }}"></div>
<div class="filter"><label for="visual">{% trans "Visual confirmation" %}</label><select id="visual" name="visual"><option value="all" {% if map_filters.visual == "all" %}selected{% endif %}>{% trans "Any report" %}</option><option value="yes" {% if map_filters.visual == "yes" %}selected{% endif %}>{% trans "Visually confirmed" %}</option><option value="no" {% if map_filters.visual == "no" %}selected{% endif %}>{% trans "Not visually confirmed" %}</option></select></div>
<button class="filter-submit" type="submit">{% trans "Apply filters" %}</button>
<span class="map-tag">{% blocktrans count count=mapped_event_count %}{{ count }} report{% plural %}{{ count }} reports{% endblocktrans %}</span>
</form>
{% include "fireworks_detect/includes/map_panel.html" %}
@@ -1,3 +1,4 @@
{% load i18n %}
<div class="review-submission" id="review-submission" role="status">
{% if error %}<div><strong>Could not submit this sample</strong><p>{{ error }}</p></div>{% else %}<div><strong>Sent to Pending</strong><p>{{ pending.original_filename }} is ready for administrator review.</p></div><a href="{% url 'fireworks_detect:events' %}">View events</a>{% endif %}
{% if error %}<div><strong>{% trans "Could not submit this sample" %}</strong><p>{{ error }}</p></div>{% else %}<div><strong>{% trans "Sent to Pending" %}</strong><p>{% blocktrans with filename=pending.original_filename %}{{ filename }} is ready for administrator review.{% endblocktrans %}</p></div><a href="{% url 'fireworks_detect:events' %}">{% trans "View events" %}</a>{% endif %}
</div>
+13 -13
View File
@@ -1,10 +1,10 @@
{% load vite %}
{% load i18n vite %}
<!DOCTYPE html>
<html lang="en" data-theme="dark">
<html lang="{{ request.LANGUAGE_CODE|default:'en' }}" data-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sound Signal · Fireworks detection</title>
<title>{% trans "Sound Signal · Fireworks detection" %}</title>
<script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.4/dist/htmx.min.js"></script>
{% vite_asset "frontend/src/entries/legacy-fireworks-home.js" %}
</head>
@@ -12,32 +12,32 @@
<main class="shell">
<div class="brand"><span class="brand-mark">✦</span> Sound Signal</div>
<section class="intro" aria-labelledby="page-title">
<p class="kicker">Audio event analysis</p>
<h1 id="page-title">See what your audio heard.</h1>
<p class="lede">Drop a recording to identify its most likely sounds. Firework-related signals are highlighted in amber; speech-related signals are marked in red for future privacy filtering.</p>
<p class="kicker">{% trans "Audio event analysis" %}</p>
<h1 id="page-title">{% trans "See what your audio heard." %}</h1>
<p class="lede">{% trans "Drop a recording to identify its most likely sounds. Firework-related signals are highlighted in amber; speech-related signals are marked in red for future privacy filtering." %}</p>
</section>
<section class="upload-card" aria-label="Upload audio for classification">
<section class="upload-card" aria-label="{% trans "Upload audio for classification" %}">
<form class="upload-form" action="{% url 'fireworks_detect:classify' %}" method="post" enctype="multipart/form-data" hx-post="{% url 'fireworks_detect:classify' %}" hx-target="#classification-results" hx-swap="innerHTML" hx-encoding="multipart/form-data" hx-indicator="#upload-indicator">
{% csrf_token %}
<label class="drop-zone" id="drop-zone">
<input class="file-input" id="audio-file" type="file" name="audio" accept="audio/*,.wav,.mp3,.m4a,.ogg,.flac,.aac,.opus" required>
<span>
<span class="upload-icon">↑</span>
<strong>Drop an audio file here</strong>
<span>or click to browse your device</span>
<strong>{% trans "Drop an audio file here" %}</strong>
<span>{% trans "or click to browse your device" %}</span>
</span>
<span class="file-name" id="file-name">No file selected</span>
<span class="file-name" id="file-name">{% trans "No file selected" %}</span>
</label>
<div class="form-footer">
<p class="file-note">WAV, MP3, M4A, OGG and more · 25 MiB maximum</p>
<button type="submit"><span class="spinner htmx-indicator" id="upload-indicator" aria-hidden="true"></span>Analyse audio</button>
<p class="file-note">{% trans "WAV, MP3, M4A, OGG and more · 25 MiB maximum" %}</p>
<button type="submit"><span class="spinner htmx-indicator" id="upload-indicator" aria-hidden="true"></span>{% trans "Analyse audio" %}</button>
</div>
</form>
<p id="upload-status" role="status" aria-live="polite"></p>
</section>
<section id="classification-results" aria-live="polite" aria-label="Classification results"></section>
<section id="classification-results" aria-live="polite" aria-label="{% trans "Classification results" %}"></section>
</main>
</body>
</html>
+5 -2
View File
@@ -45,6 +45,9 @@ class ClassificationRuleApiTests(TestCase):
class ManualPendingEventTests(TestCase):
def setUp(self):
self.client.cookies["django_language"] = "en"
def test_manual_report_creates_a_timestamped_pending_event(self):
response = self.client.post(reverse("fireworks_detect:submit_manual_pending"), {
"occurrences": "4",
@@ -128,8 +131,8 @@ class ManualPendingEventTests(TestCase):
response = self.client.get(reverse("old_home"))
self.assertEqual(response.status_code, 200)
self.assertContains(response, "Welkom Joren")
self.assertContains(response, "Open vuurwerk detector")
self.assertContains(response, "Welcome Joren")
self.assertContains(response, "Open fireworks detector")
def test_manual_event_appears_in_the_normal_event_list_with_its_details(self):
event = Event.objects.create(
+14 -13
View File
@@ -14,6 +14,7 @@ from django.core import signing
from django.shortcuts import get_object_or_404, redirect, render
from django.utils import timezone
from django.utils.dateparse import parse_date
from django.utils.translation import gettext as _
from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_http_methods
@@ -239,13 +240,13 @@ def classify_upload(request):
uploaded_file = request.FILES.get("audio")
if not uploaded_file:
return _render_error(request, "Choose an audio file before starting the analysis.")
return _render_error(request, _("Choose an audio file before starting the analysis."))
extension = Path(uploaded_file.name).suffix.lower()
if not (uploaded_file.content_type or "").startswith("audio/") and extension not in AUDIO_EXTENSIONS:
return _render_error(request, "Please upload a supported audio file (such as WAV, MP3, M4A, or OGG).")
return _render_error(request, _("Please upload a supported audio file (such as WAV, MP3, M4A, or OGG)."))
if uploaded_file.size > MAX_AUDIO_SIZE:
return _render_error(request, "This demo accepts audio files up to 25 MiB.")
return _render_error(request, _("This demo accepts audio files up to 25 MiB."))
body, content_type = _encode_audio_multipart(uploaded_file)
classifier_request = Request(
@@ -259,14 +260,14 @@ def classify_upload(request):
with urlopen(classifier_request, timeout=60) as response:
payload = json.loads(response.read().decode("utf-8"))
except HTTPError as error:
return _render_error(request, f"The classifier returned an error (HTTP {error.code}).", status=502)
return _render_error(request, _("The classifier returned an error (HTTP %(code)s).") % {"code": error.code}, status=502)
except (URLError, TimeoutError):
return _render_error(request, "The classifier could not be reached. Please try again shortly.", status=502)
return _render_error(request, _("The classifier could not be reached. Please try again shortly."), status=502)
except json.JSONDecodeError:
return _render_error(request, "The classifier returned an unreadable response.", status=502)
return _render_error(request, _("The classifier returned an unreadable response."), status=502)
if not isinstance(payload, dict):
return _render_error(request, "The classifier returned an unexpected response.", status=502)
return _render_error(request, _("The classifier returned an unexpected response."), status=502)
# Keep the raw payload in this request flow; this is the future hand-off point
# for saving the upload and its classification to a database or queue.
@@ -281,17 +282,17 @@ def submit_pending_event(request):
uploaded_file = request.FILES.get("audio")
token = request.POST.get("classification_token")
if not uploaded_file:
return render(request, "fireworks_detect/pending_submission.html", {"error": "Keep the analysed audio file selected before submitting it for review."}, status=400)
return render(request, "fireworks_detect/pending_submission.html", {"error": _("Keep the analysed audio file selected before submitting it for review.")}, status=400)
if not token:
return render(request, "fireworks_detect/pending_submission.html", {"error": "Analyse the file before submitting it for review."}, status=400)
return render(request, "fireworks_detect/pending_submission.html", {"error": _("Analyse the file before submitting it for review.")}, status=400)
try:
payload = signing.loads(token, salt="fireworks_detect.classification", max_age=60 * 60)
except signing.BadSignature:
return render(request, "fireworks_detect/pending_submission.html", {"error": "This analysis has expired. Please analyse the audio again."}, status=400)
return render(request, "fireworks_detect/pending_submission.html", {"error": _("This analysis has expired. Please analyse the audio again.")}, status=400)
if not isinstance(payload, dict):
return render(request, "fireworks_detect/pending_submission.html", {"error": "The saved analysis is not valid."}, status=400)
return render(request, "fireworks_detect/pending_submission.html", {"error": _("The saved analysis is not valid.")}, status=400)
pending = PendingEvent.objects.create(
audio_file=uploaded_file,
@@ -341,7 +342,7 @@ def submit_manual_pending_event(request):
return render(
request,
"fireworks_detect/manual_pending_submission.html",
{"error": "Choose between 1 and 1,000 occurrences."},
{"error": _("Choose between 1 and 1,000 occurrences.")},
status=400,
)
@@ -379,7 +380,7 @@ def event_detail(request, event_id):
def _audio_response(record):
if not record.audio_file:
raise Http404("No audio is attached to this record.")
raise Http404(_("No audio is attached to this record."))
content_type = mimetypes.guess_type(record.audio_file.name)[0] or "application/octet-stream"
return FileResponse(record.audio_file.open("rb"), content_type=content_type)