From afa8ed8af5fd6492785f88081b847cfb461599f8 Mon Sep 17 00:00:00 2001 From: Jason Cameron Date: Mon, 4 Dec 2023 17:10:35 -0500 Subject: [PATCH] added checking for skipping --- core/templates/core/qr.html | 6 +++++- core/views/qr.py | 11 +++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/core/templates/core/qr.html b/core/templates/core/qr.html index 5e2d5c4..4f7043d 100644 --- a/core/templates/core/qr.html +++ b/core/templates/core/qr.html @@ -69,5 +69,9 @@ {% translate 'Oh ho? What lieth there? Tis the light at the end of the tunnel!
Congratulations valiant scavenger and thank you for playing!' %} {% endif %} - {% endif %} + {% else %} { + +{% translate 'Incorrect QR code, please read your hint again or contact an organizer' %} + +{% endif %} {% endblock %} diff --git a/core/views/qr.py b/core/views/qr.py index 177bcac..ff08d0d 100644 --- a/core/views/qr.py +++ b/core/views/qr.py @@ -104,10 +104,14 @@ def wrapped(*args, **kwargs): @during_hunt def qr(request, key): context = dict(first=False) - context["qr"] = qr = get_object_or_404(QrCode, key=key) context["qr"]: QrCode + context["qr"] = qr = get_object_or_404(QrCode, key=key) codes = QrCode.code_pks(request.user.team) - if qr.id not in codes: + if qr.id != codes[request.user.team.current_qr_i]: + """ + Either the user skipped ahead (is on path) or they found a random qr code (not on path) + Either way... not allowed + """ context["offpath"] = True return render(request, "core/qr.html", context=context) i = codes.index(qr.id) @@ -115,8 +119,7 @@ def qr(request, key): None if len(codes) <= (j := i + 1) else QrCode.objects.get(id=codes[j]) ) context["logic_hint"] = LogicPuzzleHint.get_clue(request.user.team) - # TODO: check if they skipped? - request.user.team.update_current_qr_i(i) + request.user.team.update_current_qr_i(i + 1) return render(request, "core/qr.html", context=context)