From 511b3c3777bfb20e443ddc5d2963fc2495e7eed2 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 27 Oct 2025 11:54:02 +0000 Subject: [PATCH] Add skip and next buttons to question review with corresponding JavaScript functionality --- generic/views.py | 11 +++++ sbas/templates/sbas/base.html | 2 +- .../sbas/question_review_question.html | 42 +++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/generic/views.py b/generic/views.py index 4124abfe..e6ed0df8 100644 --- a/generic/views.py +++ b/generic/views.py @@ -3073,6 +3073,13 @@ class GenericViewBase: # Read filters category = request.POST.get("category") or request.GET.get("category") status = request.POST.get("status") or request.GET.get("status") or "ANY" + # How many matching questions to skip (useful for Skip button). Expected integer >= 0. + try: + skip = int(request.POST.get("skip") or request.GET.get("skip") or 0) + if skip < 0: + skip = 0 + except Exception: + skip = 0 # Build base queryset of questions for this app qs = self.question_object.objects.all().order_by("pk") @@ -3120,6 +3127,10 @@ class GenericViewBase: match = True if match: + # If caller asked us to skip N matches, decrement and continue until skip==0 + if skip and skip > 0: + skip -= 1 + continue form = QuestionReviewForm() return render(request, f"{self.app_name}/question_review_question.html", {"question": question, "form": form, "app_name": self.app_name, "filters": {"category": category, "status": status}}) diff --git a/sbas/templates/sbas/base.html b/sbas/templates/sbas/base.html index e3d9861d..f08cd894 100644 --- a/sbas/templates/sbas/base.html +++ b/sbas/templates/sbas/base.html @@ -23,7 +23,7 @@ diff --git a/sbas/templates/sbas/question_review_question.html b/sbas/templates/sbas/question_review_question.html index c55ebfe5..2cac89fc 100644 --- a/sbas/templates/sbas/question_review_question.html +++ b/sbas/templates/sbas/question_review_question.html @@ -117,6 +117,48 @@ {% comment %} The included partial contains its own
with hx-post. Do not wrap it in another form (nested forms break submission). {% endcomment %} {% include 'generic/partials/question_review_form.html' with app_name='sbas' question=question form=form %} +
+ {# Skip increments a 'skip' query param used by the view to skip matching questions #} + + + {# Next should only be enabled after a successful Save (server will send HX-Trigger 'reviewSaved') #} + +
+ + +
{# Placeholder while HTMX fetches review/block #}