Skip to content

Commit 50ac222

Browse files
committed
Fix off by one bug
1 parent be2becc commit 50ac222

5 files changed

Lines changed: 19 additions & 9 deletions

File tree

core/fixtures/qrcodes.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"model": "core.qrcode", "pk": 1, "fields": {"short": "sacboard", "location": "SAC Member Board", "notes": "slap qr code on derek", "key": "rx1vYuTFKknte8KteBhpOHO4GEs0SeexMjFy7VU5Rf7joWZ_gAC_iIPOzPKYex6x"}}, {"model": "core.qrcode", "pk": 2, "fields": {"short": "wabagradpic", "location": "Graduating Classes", "notes": "slap on justin", "key": "rD2sKjdDi8IR6Q9THY9scrY9xWWgB6osu3p2YnD1XYYnooWFxBUJNVZxVrjXAe8T"}}, {"model": "core.qrcode", "pk": 3, "fields": {"short": "portable", "location": "Portable 3", "notes": "laminate code and stick to outside of portable", "key": "THslHUyqdeIdM_nJHrroDkPuFCxXn_K48OkDl1c6kaJis-rszj70QtD0rMrT0Se_"}}, {"model": "core.qrcode", "pk": 4, "fields": {"short": "endinglocation", "location": "Zoe's Locker (2008)", "notes": "Lock combo: 35, 6, 31\r\n\r\nSecond floor, ICS hall", "key": "fM7r9jkYjix2Jybtbt-7GcPmjPaGy1_U84ohoCIRAaLsfrHOGGG27xww0aVqSHZA"}}, {"model": "core.qrcode", "pk": 5, "fields": {"short": "pooldoor", "location": "exit 6 \"pool\" door heater", "notes": "laminate and slap on heater that's somewhat hidden", "key": "FK-mm_gSbpnWVMFXauXk2WhG27-bkGxsk1Ug2LujED7CnYHzPQBWmPu605nzgXUG"}}, {"model": "core.qrcode", "pk": 6, "fields": {"short": "artshallwayceiling", "location": "end of arts hallway ceiling", "notes": "laminate and slap on ceiling somehow", "key": "L_AH1eiAhY_yfAlhWdDpu5oye4yBgwJ8kr2bM390Fv8cJWOIHkJOOPtfO9m1F0lS"}}, {"model": "core.qrcode", "pk": 7, "fields": {"short": "librarydisplay", "location": "display case in front of library", "notes": "laminate and slap somewhere where it's somewhat hidden", "key": "AQXIy6hTQXVvQruNTE1MyQ4hJdsf8GMSaaG5eWK2DDv-T9Ks9fpqMAA3H2DTwNEZ"}}, {"model": "core.qrcode", "pk": 9, "fields": {"short": "fallsportsrecapboard", "location": "athletic council fall sports recap board", "notes": "laminate and stick it over athletic council qr code\r\nfor reference it's across from sac board", "key": "tm6H0--T02ykVJyq-upgpLeqhJ5GGJhiYk5BRa3mSqpXbHNNSYxkbr_wJ2rGU8Xt"}}, {"model": "core.qrcode", "pk": 11, "fields": {"short": "santa", "location": "Display case by library with the glass window.", "notes": ":D idk I need to put smth here?", "key": "UUJDq-GguUMTkZPsiREWVSqz1wOfj_htEC_Esnyly-DXtFadoMSjpZsM8CjKeJV3"}}, {"model": "core.qrcode", "pk": 12, "fields": {"short": "where dreams die", "location": "ICS office rm 233", "notes": ":D", "key": "yXO7uiCnR0lZXre5SWppyvNQ04JN-0qbDpwuJ7py51b69c19f6uUUCVsZxwV0oNf"}}, {"model": "core.qrcode", "pk": 13, "fields": {"short": "robot.", "location": "The giant vacuum for tech design", "notes": "r", "key": "UEcl-k61yKZC0HkUIR0f-rKshGaKqR53CV09-hDz8E6x5gKord6WtQlcOHnWXeht"}}, {"model": "core.qrcode", "pk": 14, "fields": {"short": "KAT", "location": "by the door to get into the AV room in the cafatorium", "notes": "nthz", "key": "0ARn4MRuFGcXpjz1SYz8F9NtB-GeoRUlo7M0XlBUz3q6uIRRG851wl94KDCuS1W6"}}, {"model": "core.qrcode", "pk": 15, "fields": {"short": "School Board", "location": "Changeables letters board at the front of the school", "notes": ".", "key": "wSpLdsHAZmq6686e0Io9NG_y2kzh1py2e3SEFtOvipp0dKASWLoFoqc6Pmx4JpUa"}}, {"model": "core.qrcode", "pk": 17, "fields": {"short": "Sporty Person", "location": "Gym hallway athlete", "notes": ".", "key": "kyTAHO8yeyjvGKgPTqsnFxshWMut8Qp4OMdaaEeCsXvS6Cqeq-1X4WxWJW1xg8Xe"}}, {"model": "core.qrcode", "pk": 18, "fields": {"short": "readingchairfacingwall", "location": "In the library, in the section with reading chairs, on the back of the chair that is facing directly towards the wall", "notes": ".", "key": "3ulXyU5Pk7LD8PKr6ZfG73JZzUoyPvEGkF88-HNFuPrMnNfDXT8t9_dN7AacNCi7"}}, {"model": "core.qrcode", "pk": 19, "fields": {"short": "sheetmusicwall", "location": "Music hallway, in the unused Grade 10s folder for music", "notes": ".", "key": "T-OUZDrwqxXil5ySDBYsfTBsYGmCns5yIBugKU38VM0dlekOhPZJsP54Q8NwPdI3"}}, {"model": "core.qrcode", "pk": 20, "fields": {"short": "e", "location": "locker handle across dance", "notes": "", "key": "k5zRJtilrLZ4UYzh7Y4XiFAJdTeqHqP4duweJ5AqxRIGiVfV24xhD7svv6MW_FCK"}}, {"model": "core.qrcode", "pk": 21, "fields": {"short": "ee", "location": "behind app poster near caf store", "notes": "", "key": "eaQcxjpg6tQBfKHoaH2V3Ta0jcl8ba_SVkKgpDfeX9oAKWUmjzePQ2dst9M9HqYi"}}, {"model": "core.qrcode", "pk": 22, "fields": {"short": "eee", "location": "science hallway on a ms law aditl poster", "notes": "", "key": "MzIKxxxOVqC-KJbyPHICzR4gX-qNAZXhjpwXxxxzCFSXlaaiy7apShaddMKoAmg0"}}, {"model": "core.qrcode", "pk": 23, "fields": {"short": "eeee", "location": "woodshop board", "notes": "", "key": "7koMBJDbEc1SJd0eIkXWQckE_Pz9NVd5UtcCqG5de-v5T9sQ4KaDpVtrpGOqPx1b"}}, {"model": "core.qrcode", "pk": 24, "fields": {"short": "vox 1", "location": "TV OUTSIDE OFFICE", "notes": "helo", "key": "mXPWoLeTD7sdOvLKexvcNDcTurSHRydwbt0JusP0kl5tett2bmFMyivCRwLf87AJ"}}, {"model": "core.qrcode", "pk": 25, "fields": {"short": "vox 2", "location": "TV IN GUIDANCE", "notes": "gbye", "key": "UQ51Pi49J9oko2Ml6iZPnasBZQuQH4PoHWzPOWmhgSXwDZwMXGgOot2rwd2BQkmt"}}, {"model": "core.qrcode", "pk": 26, "fields": {"short": "88", "location": "STAGE PIANO", "notes": "greets", "key": "yaUoFPrWu3SPa2wd4WCD1oqRLEOV_iYQNzDEuq93T81QAScFGpbvjQw-76g2fGgP"}}, {"model": "core.qrcode", "pk": 27, "fields": {"short": "eat knob gild", "location": "CAF DOOR FRAME", "notes": "", "key": "Xgi_Fz_D32j84JSp8q3hY8-lOWLn5YykXRNdVUo8kin-UVUdBaH4aIzC0G0tgD7D"}}]
1+
[{"model": "core.qrcode", "pk": 1, "fields": {"short": "sacboard", "location": "SAC Member Board", "notes": "slap qr code on derek", "key": "rx1vYuTFKknte8KteBhpOHO4GEs0SeexMjFy7VU5Rf7joWZ_gAC_iIPOzPKYex6x", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 2, "fields": {"short": "wabagradpic", "location": "Graduating Classes", "notes": "slap on justin", "key": "rD2sKjdDi8IR6Q9THY9scrY9xWWgB6osu3p2YnD1XYYnooWFxBUJNVZxVrjXAe8T", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 3, "fields": {"short": "portable", "location": "Portable 3", "notes": "laminate code and stick to outside of portable", "key": "THslHUyqdeIdM_nJHrroDkPuFCxXn_K48OkDl1c6kaJis-rszj70QtD0rMrT0Se_", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 4, "fields": {"short": "endinglocation", "location": "Zoe's Locker (2008)", "notes": "Lock combo: 35, 6, 31\r\n\r\nSecond floor, ICS hall", "key": "fM7r9jkYjix2Jybtbt-7GcPmjPaGy1_U84ohoCIRAaLsfrHOGGG27xww0aVqSHZA", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 5, "fields": {"short": "pooldoor", "location": "exit 6 \"pool\" door heater", "notes": "laminate and slap on heater that's somewhat hidden", "key": "FK-mm_gSbpnWVMFXauXk2WhG27-bkGxsk1Ug2LujED7CnYHzPQBWmPu605nzgXUG", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 6, "fields": {"short": "artshallwayceiling", "location": "end of arts hallway ceiling", "notes": "laminate and slap on ceiling somehow", "key": "L_AH1eiAhY_yfAlhWdDpu5oye4yBgwJ8kr2bM390Fv8cJWOIHkJOOPtfO9m1F0lS", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 7, "fields": {"short": "librarydisplay", "location": "display case in front of library", "notes": "laminate and slap somewhere where it's somewhat hidden", "key": "AQXIy6hTQXVvQruNTE1MyQ4hJdsf8GMSaaG5eWK2DDv-T9Ks9fpqMAA3H2DTwNEZ", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 9, "fields": {"short": "fallsportsrecapboard", "location": "athletic council fall sports recap board", "notes": "laminate and stick it over athletic council qr code\r\nfor reference it's across from sac board", "key": "tm6H0--T02ykVJyq-upgpLeqhJ5GGJhiYk5BRa3mSqpXbHNNSYxkbr_wJ2rGU8Xt", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 11, "fields": {"short": "santa", "location": "Display case by library with the glass window.", "notes": ":D idk I need to put smth here?", "key": "UUJDq-GguUMTkZPsiREWVSqz1wOfj_htEC_Esnyly-DXtFadoMSjpZsM8CjKeJV3", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 12, "fields": {"short": "where dreams die", "location": "ICS office rm 233", "notes": ":D", "key": "yXO7uiCnR0lZXre5SWppyvNQ04JN-0qbDpwuJ7py51b69c19f6uUUCVsZxwV0oNf", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 13, "fields": {"short": "robot.", "location": "The giant vacuum for tech design", "notes": "r", "key": "UEcl-k61yKZC0HkUIR0f-rKshGaKqR53CV09-hDz8E6x5gKord6WtQlcOHnWXeht", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 14, "fields": {"short": "KAT", "location": "by the door to get into the AV room in the cafatorium", "notes": "nthz", "key": "0ARn4MRuFGcXpjz1SYz8F9NtB-GeoRUlo7M0XlBUz3q6uIRRG851wl94KDCuS1W6", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 15, "fields": {"short": "School Board", "location": "Changeables letters board at the front of the school", "notes": ".", "key": "wSpLdsHAZmq6686e0Io9NG_y2kzh1py2e3SEFtOvipp0dKASWLoFoqc6Pmx4JpUa", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 17, "fields": {"short": "Sporty Person", "location": "Gym hallway athlete", "notes": ".", "key": "kyTAHO8yeyjvGKgPTqsnFxshWMut8Qp4OMdaaEeCsXvS6Cqeq-1X4WxWJW1xg8Xe", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 18, "fields": {"short": "readingchairfacingwall", "location": "In the library, in the section with reading chairs, on the back of the chair that is facing directly towards the wall", "notes": ".", "key": "3ulXyU5Pk7LD8PKr6ZfG73JZzUoyPvEGkF88-HNFuPrMnNfDXT8t9_dN7AacNCi7", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 19, "fields": {"short": "sheetmusicwall", "location": "Music hallway, in the unused Grade 10s folder for music", "notes": ".", "key": "T-OUZDrwqxXil5ySDBYsfTBsYGmCns5yIBugKU38VM0dlekOhPZJsP54Q8NwPdI3", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 20, "fields": {"short": "e", "location": "locker handle across dance", "notes": "", "key": "k5zRJtilrLZ4UYzh7Y4XiFAJdTeqHqP4duweJ5AqxRIGiVfV24xhD7svv6MW_FCK", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 21, "fields": {"short": "ee", "location": "behind app poster near caf store", "notes": "", "key": "eaQcxjpg6tQBfKHoaH2V3Ta0jcl8ba_SVkKgpDfeX9oAKWUmjzePQ2dst9M9HqYi", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 22, "fields": {"short": "eee", "location": "science hallway on a ms law aditl poster", "notes": "", "key": "MzIKxxxOVqC-KJbyPHICzR4gX-qNAZXhjpwXxxxzCFSXlaaiy7apShaddMKoAmg0", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 23, "fields": {"short": "eeee", "location": "woodshop board", "notes": "", "key": "7koMBJDbEc1SJd0eIkXWQckE_Pz9NVd5UtcCqG5de-v5T9sQ4KaDpVtrpGOqPx1b", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 24, "fields": {"short": "vox 1", "location": "TV OUTSIDE OFFICE", "notes": "helo", "key": "mXPWoLeTD7sdOvLKexvcNDcTurSHRydwbt0JusP0kl5tett2bmFMyivCRwLf87AJ", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 25, "fields": {"short": "vox 2", "location": "TV IN GUIDANCE", "notes": "gbye", "key": "UQ51Pi49J9oko2Ml6iZPnasBZQuQH4PoHWzPOWmhgSXwDZwMXGgOot2rwd2BQkmt", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 26, "fields": {"short": "88", "location": "STAGE PIANO", "notes": "greets", "key": "yaUoFPrWu3SPa2wd4WCD1oqRLEOV_iYQNzDEuq93T81QAScFGpbvjQw-76g2fGgP", "created_at": "2025-11-24T21:14:58.498615-05:00"}}, {"model": "core.qrcode", "pk": 27, "fields": {"short": "eat knob gild", "location": "CAF DOOR FRAME", "notes": "", "key": "Xgi_Fz_D32j84JSp8q3hY8-lOWLn5YykXRNdVUo8kin-UVUdBaH4aIzC0G0tgD7D", "created_at": "2025-11-24T21:14:58.498615-05:00"}}]

core/migrations/0019_hunt_remove_team_is_active_remove_user_team_and_more.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ class Migration(migrations.Migration):
193193
to=settings.AUTH_USER_MODEL,
194194
),
195195
),
196-
migrations.RunPython(create_hunt, reverse_code=undo_create_hunt),
196+
# migrations.RunPython(create_hunt, reverse_code=undo_create_hunt),
197197
migrations.AddField(
198198
model_name="logicpuzzlehint",
199199
name="hunt",

core/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ class Hunt(models.Model):
260260
)
261261
path_length = models.PositiveSmallIntegerField(
262262
default=13,
263-
help_text="Length of the path: The amount of codes each time will have to find before the end. (not including start/end)",
263+
help_text="Length of the path: The amount of codes each team will have to find before the end. (not including start/end)",
264264
)
265265
starting_location = models.ForeignKey(
266266
QrCode,
@@ -427,14 +427,14 @@ def get_clues(cls, team: Team):
427427
hint.hint
428428
for hint in list(
429429
LogicPuzzleHint.objects.filter(
430-
hunt=team.hunt, qr_index__lte=team.qr_len
430+
hunt=team.hunt, qr_index__lt=team.qr_len
431431
)
432432
)
433433
]
434434

435435
@classmethod
436436
def get_clue(cls, team: Team) -> str | None:
437-
hint = cls.objects.filter(hunt=team.hunt, qr_index=team.qr_len).first()
437+
hint = cls.objects.filter(hunt=team.hunt, qr_index=(team.qr_len - 1)).first()
438438
try:
439439
return hint.hint
440440
except (AttributeError, cls.DoesNotExist):

core/templates/core/qr.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
{% hint qr request.user.current_team as hint %}
3535
<span class="hint-content">{{ hint |mistune }}</span>
3636
{% if request.user.is_superuser %}
37-
<span style="font-size: 0.5rem"><a class="link" href="{% url 'admin:core_qrcode_change' object_id=qr.id %}">{% translate "change" %}</a>)</span>
37+
<span style="font-size: 0.5rem">(<a class="link" href="{% url 'admin:core_qrcode_change' object_id=qr.id %}">{% translate "change" %}</a>)</span>
3838
{% endif %}
3939
</div>
4040
{% endif %}
@@ -55,7 +55,7 @@
5555
{% hint nexthint request.user.current_team as hint %}
5656
<span class="hint-content">{{ hint|mistune }}</span>
5757
{% if request.user.is_superuser %}
58-
<span style="font-size: 0.5rem"><a class="link" href="{% url 'admin:core_qrcode_change' object_id=nexthint.id %}">{% translate "change" %}</a>)</span>
58+
<span style="font-size: 0.5rem">(<a class="link" href="{% url 'admin:core_qrcode_change' object_id=nexthint.id %}">{% translate "change" %}</a>)</span>
5959
{% endif %}
6060

6161
{% if logic_hint %}
@@ -67,6 +67,16 @@
6767
</div>
6868
{% endif %}
6969
{% else %}
70+
{% if logic_hint %}
71+
{% if not first and qr is not None and on_qr %}
72+
<hr class="separator"/>
73+
{% endif %}
74+
<div class="logic">
75+
<p style="font-size: 1.5rem">Final Logic Hint:</p>
76+
<span >{{ logic_hint }}</span>
77+
<p style="font-size: 1.3rem">you can view all of your logic hints <a href={% url 'logic_clues' %}>here</a> </p>
78+
</div>
79+
{% endif %}
7080
{% hunt_ending_text request.user.current_team.hunt %}
7181
{% translate 'Oh ho? What lieth there? Tis the light at the end of the tunnel! <br /> Congratulations valiant scavenger and thank you for playing!' %}
7282
{% endif %}

core/views/qr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ def qr(request, key):
157157
context["nexthint"] = (
158158
None if len(codes) <= (j := i + 1) else QrCode.objects.get(id=codes[j])
159159
)
160-
context["logic_hint"] = LogicPuzzleHint.get_clue(request.user.current_team)
161160
request.user.current_team.update_current_qr_i(i + 1)
161+
context["logic_hint"] = LogicPuzzleHint.get_clue(request.user.current_team)
162162
return render(request, "core/qr.html", context=context)
163163

164164

@@ -174,7 +174,7 @@ def qr_first(request):
174174
return redirect(reverse("qr_current"))
175175
codes = QrCode.codes(request.user.current_team)
176176
context["nexthint"] = codes[0]
177-
context["logic_hint"] = LogicPuzzleHint.get_clue(request.user.current_team)
177+
# context["logic_hint"] = LogicPuzzleHint.get_clue(request.user.current_team)
178178
return render(request, "core/qr.html", context=context)
179179

180180

0 commit comments

Comments
 (0)