manual submission redesign phase B
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
{% load i18n %}
|
||||
<div class="manual-direction-panel{% if measuring %} manual-direction-panel--measuring{% endif %}" id="manual-direction-panel">
|
||||
{% if measuring %}
|
||||
<div class="manual-direction-panel__topline">
|
||||
<strong class="manual-direction-panel__heading">{% trans "Capture direction" %}</strong>
|
||||
<button class="manual-direction-panel__close" type="button" hx-get="{% url 'fireworks_detect:manual_direction_panel' %}" hx-target="#manual-direction-panel" hx-swap="outerHTML" aria-label="{% trans 'Close direction capture' %}">×</button>
|
||||
</div>
|
||||
<p class="manual-direction-panel__copy">{% trans "Point the top of your phone toward the fireworks, then capture a single compass reading." %}</p>
|
||||
<div id="manual-direction-status" class="manual-direction-panel__status" aria-live="polite"></div>
|
||||
<button id="manual-capture-direction" class="manual-direction-panel__button" type="button">{% trans "Start measuring direction" %}</button>
|
||||
{% else %}
|
||||
<strong class="manual-direction-panel__heading">{% trans "Direction" %} <span>({% trans "optional" %})</span></strong>
|
||||
<p id="manual-direction-summary" class="manual-direction-panel__summary">{% trans "Not captured" %}</p>
|
||||
<button class="manual-direction-panel__open" type="button" hx-get="{% url 'fireworks_detect:manual_direction_panel' %}?mode=measure" hx-target="#manual-direction-panel" hx-swap="outerHTML">{% trans "Capture direction" %}</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
@@ -13,16 +13,15 @@
|
||||
<input id="manual-direction-accuracy" name="direction_accuracy_degrees" type="hidden">
|
||||
<div class="manual-report__primary">
|
||||
<div class="manual-report__quantity">
|
||||
<label class="manual-report__label" for="manual-occurrences">{% trans "Number of occurrences" %}</label>
|
||||
<input id="manual-occurrences" name="occurrences" type="number" min="1" max="1000" value="1" required inputmode="numeric">
|
||||
<label class="manual-report__label" for="manual-occurrences">{% trans "How many times did you hear it?" %}</label>
|
||||
<div class="manual-report__stepper">
|
||||
<button id="manual-decrease" type="button" aria-label="{% trans 'Decrease occurrences' %}">−</button>
|
||||
<input id="manual-occurrences" name="occurrences" type="number" min="1" max="1000" value="1" required inputmode="numeric">
|
||||
<button id="manual-increase" type="button" aria-label="{% trans 'Increase occurrences' %}">+</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="manual-direction-panel" id="manual-direction-panel" hidden>
|
||||
<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">{% trans "I heard fireworks — send to Pending" %}</button>
|
||||
{% include "fireworks_detect/includes/manual_direction_panel.html" %}
|
||||
<button id="manual-submit" class="manual-report__submit" type="button"><span aria-hidden="true">🔥</span> {% trans "I heard fireworks" %}</button>
|
||||
</div>
|
||||
<section class="manual-report__supporting" aria-labelledby="manual-listening-title">
|
||||
<h3 id="manual-listening-title">{% trans "Automatic detection" %}</h3>
|
||||
|
||||
@@ -157,9 +157,12 @@ class ManualPendingEventTests(TestCase):
|
||||
response = self.client.get(reverse("hello"))
|
||||
|
||||
self.assertContains(response, "Report fireworks now")
|
||||
self.assertContains(response, "I heard fireworks — send to Pending")
|
||||
self.assertContains(response, "I heard fireworks")
|
||||
self.assertContains(response, "Capture direction")
|
||||
self.assertContains(response, 'manual-direction-panel" hidden')
|
||||
self.assertContains(response, 'id="manual-decrease"')
|
||||
self.assertContains(response, 'id="manual-increase"')
|
||||
self.assertContains(response, 'id="manual-direction-panel"')
|
||||
self.assertContains(response, 'hx-get="/fireworks/manual-direction/?mode=measure"')
|
||||
self.assertContains(response, 'id="manual-compass"')
|
||||
self.assertContains(response, 'aria-label="Compass direction" hidden')
|
||||
self.assertContains(response, "htmx.min.js")
|
||||
@@ -169,6 +172,16 @@ class ManualPendingEventTests(TestCase):
|
||||
self.assertContains(response, "Open map controls")
|
||||
self.assertContains(response, "Classify a recording")
|
||||
|
||||
def test_direction_subsection_opens_and_closes_with_htmx_fragments(self):
|
||||
url = reverse("fireworks_detect:manual_direction_panel")
|
||||
measuring = self.client.get(url, {"mode": "measure"}, HTTP_HX_REQUEST="true")
|
||||
self.assertContains(measuring, 'id="manual-capture-direction"')
|
||||
self.assertContains(measuring, 'hx-target="#manual-direction-panel"')
|
||||
|
||||
closed = self.client.get(url, HTTP_HX_REQUEST="true")
|
||||
self.assertContains(closed, 'id="manual-direction-summary"')
|
||||
self.assertNotContains(closed, 'id="manual-capture-direction"')
|
||||
|
||||
def test_old_route_preserves_the_previous_landing_page(self):
|
||||
response = self.client.get(reverse("old_home"))
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ from .views import (
|
||||
fireworks_map_view,
|
||||
fireworks_view,
|
||||
pending_audio,
|
||||
manual_direction_panel,
|
||||
submit_manual_pending_event,
|
||||
submit_pending_event,
|
||||
sensor_heartbeat,
|
||||
@@ -27,6 +28,7 @@ urlpatterns = [
|
||||
path("heartbeat/", sensor_heartbeat, name="sensor_heartbeat"),
|
||||
path("submit-pending/", submit_pending_event, name="submit_pending"),
|
||||
path("submit-manual-pending/", submit_manual_pending_event, name="submit_manual_pending"),
|
||||
path("manual-direction/", manual_direction_panel, name="manual_direction_panel"),
|
||||
path("events/", events_view, name="events"),
|
||||
path("events/list/", events_list, name="events_list"),
|
||||
path("admin-audio/pending/<int:event_id>/", pending_audio, name="pending_audio"),
|
||||
|
||||
@@ -363,6 +363,15 @@ def _manual_direction(request):
|
||||
accuracy = None
|
||||
return heading, accuracy
|
||||
|
||||
|
||||
@require_http_methods(["GET"])
|
||||
@never_cache
|
||||
def manual_direction_panel(request):
|
||||
return render(request, "fireworks_detect/includes/manual_direction_panel.html", {
|
||||
"measuring": request.GET.get("mode") == "measure",
|
||||
})
|
||||
|
||||
|
||||
@require_http_methods(["POST"])
|
||||
@never_cache
|
||||
def submit_manual_pending_event(request):
|
||||
|
||||
Reference in New Issue
Block a user