Skip to content

Commit

Permalink
fix: bug that caused ppl to skip when they reloaded on /current ehehe…
Browse files Browse the repository at this point in the history
…hehe

remove catalog since it's not used

+ fmt
  • Loading branch information
JasonLovesDoggo committed Dec 17, 2023
1 parent 1074de0 commit 12a3567
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .idea/dataSources.local.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def code_pks(cls, team: "Team"):
hunt_codes = hunt.middle_locations.all()
pks = [a["pk"] for a in hunt_codes.values("pk")]
r.shuffle(pks)
pks = pks[: hunt.path_length]
pks = pks[: hunt.path_length] # cut qr's to max ( path length )
if hunt_end := hunt.ending_location:
pks.append(hunt_end.id)
if hunt_start := hunt.starting_location:
Expand Down
1 change: 0 additions & 1 deletion core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
path("qr/<str:key>", qr.qr, name="qr"),
path("first", qr.qr_first, name="qr_first"),
path("current", qr.qr_current, name="qr_current"),
path("catalog", qr.qr_catalog, name="qr_catalog"),
path("signal", qr.qr_signal, name="qr_signal"),
path("team", team.team, name="team"),
path("team/join/", team.join, name="join"),
Expand Down
19 changes: 3 additions & 16 deletions core/views/qr.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,30 +180,17 @@ def qr_first(request):
@during_hunt
def qr_current(request):
i = request.user.current_team.current_qr_i
first_ = i == 0
if first_:
if i == 0: # on first qr code
return redirect(reverse("qr_first"))
context = dict(first=first_, current=True)
i -= 1 # we want the index that they are AT not the next one
context = dict(current=True)
codes = QrCode.codes(request.user.current_team)
context["qr"] = codes[i]
context["nexthint"] = None if len(codes) <= (j := i + 1) else codes[j]
context["logic_hint"] = LogicPuzzleHint.get_clue(request.user.current_team)
return render(request, "core/qr.html", context=context)


@login_required
@require_http_methods(["GET", "POST"])
@team_required
@during_hunt
def qr_catalog(request):
i = request.user.current_team.current_qr_i
if i == 0:
return redirect(reverse("qr_first"))
context = dict(current=True)
context["qr"] = QrCode.codes(request.user.current_team)[:i] # i + 1?
return render(request, "core/qr_catalog.html", context=context)


global_notifs = Signal()


Expand Down

0 comments on commit 12a3567

Please sign in to comment.