Skip to content

Commit

Permalink
added checking for skipping
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLovesDoggo committed Dec 4, 2023
1 parent bfa56b2 commit afa8ed8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 5 additions & 1 deletion core/templates/core/qr.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,9 @@
{% translate 'Oh ho? What lieth there? Tis the light at the end of the tunnel! <br /> Congratulations valiant scavenger and thank you for playing!' %}
{% endif %}
</div></div> <!-- Why does this exist.. -->
{% endif %}
{% else %} {

{% translate 'Incorrect QR code, please read your hint again or contact an organizer' %}

{% endif %}
{% endblock %}
11 changes: 7 additions & 4 deletions core/views/qr.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,22 @@ 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)
context["nextqr"] = (
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)


Expand Down

0 comments on commit afa8ed8

Please sign in to comment.