Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

so no merge conflicts #16

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0b49c39
Added start/end via current hunt
JasonLovesDoggo Dec 3, 2023
0e57709
I'm clownin
JasonLovesDoggo Dec 3, 2023
701f97c
switched all references of settings.start or end to Hunt start/end
JasonLovesDoggo Dec 3, 2023
c4c3745
format
Dec 3, 2023
b2889e9
.idea then I sleep
JasonLovesDoggo Dec 3, 2023
22e8030
time sensitive + cleaner
JasonLovesDoggo Dec 3, 2023
5b189c0
updated .gitignore
JasonLovesDoggo Dec 3, 2023
775a010
updated .gitignore
JasonLovesDoggo Dec 3, 2023
cfca466
Updates credits
JasonLovesDoggo Dec 3, 2023
9982a27
migrations go brrt
JasonLovesDoggo Dec 3, 2023
e47586a
format
Dec 3, 2023
c1df39b
Added some helper fields to Hunt
JasonLovesDoggo Dec 3, 2023
9c65374
reamed after_start to during_hunt to reflect it's internal changes
JasonLovesDoggo Dec 3, 2023
f643162
renamed Hunt.early_access_users to Hunt.testers
JasonLovesDoggo Dec 3, 2023
d65e2fd
Merge remote-tracking branch 'origin/temp' into temp
JasonLovesDoggo Dec 3, 2023
1aec86c
add manual migration (untested)
JasonLovesDoggo Dec 3, 2023
86ca833
add scavenger.iml to gitignore since I have different configs on win/…
JasonLovesDoggo Dec 4, 2023
29a39ea
Fixed incorrect ternary op
JasonLovesDoggo Dec 4, 2023
2c4ac15
adds black.
JasonLovesDoggo Dec 4, 2023
4e0506e
added dynamic hunt naming
JasonLovesDoggo Dec 4, 2023
5dc0256
Updated usages to support joining a team before the event started
JasonLovesDoggo Dec 4, 2023
c3c008a
format
Dec 4, 2023
33b493c
docs: improved docs for starting, middle and ending locations.
JasonLovesDoggo Dec 4, 2023
6654503
format
Dec 4, 2023
a42184a
fix: assigning hunt as bool
JasonLovesDoggo Dec 4, 2023
29f0dae
remove useless assignment
JasonLovesDoggo Dec 4, 2023
49d7986
remove useless assignment
JasonLovesDoggo Dec 4, 2023
13dc668
fix typo
JasonLovesDoggo Dec 4, 2023
56ec5cd
fix typo
JasonLovesDoggo Dec 4, 2023
a479ae5
fix change to list
JasonLovesDoggo Dec 4, 2023
5114158
format
Dec 4, 2023
3fc3d80
what
JasonLovesDoggo Dec 4, 2023
a6f64fc
typehinting
JasonLovesDoggo Dec 4, 2023
8de9654
fix reference to old/new Queryset
JasonLovesDoggo Dec 4, 2023
bfa56b2
little TODO
JasonLovesDoggo Dec 4, 2023
5411871
format
Dec 4, 2023
afa8ed8
added checking for skipping
JasonLovesDoggo Dec 4, 2023
a310f26
Merge remote-tracking branch 'origin/temp' into temp
JasonLovesDoggo Dec 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ __pycache__
.direnv
/db.sqlite3
/venv
.idea/workspace.xml
.idea/misc.xml
.idea/scavenger.iml
```
7 changes: 6 additions & 1 deletion .idea/dataSources.local.xml

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

7 changes: 0 additions & 7 deletions .idea/misc.xml

This file was deleted.

27 changes: 0 additions & 27 deletions .idea/runConfigurations/Scavenger_.xml

This file was deleted.

2 changes: 1 addition & 1 deletion .idea/scavenger.iml

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

457 changes: 0 additions & 457 deletions .idea/workspace.xml

This file was deleted.

26 changes: 23 additions & 3 deletions core/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.contrib import admin
from django.contrib import admin, messages
from django.contrib.auth.admin import UserAdmin as UserAdmin_
from django.contrib.auth.models import Group
from django.utils.safestring import mark_safe
Expand Down Expand Up @@ -113,13 +113,33 @@ def url(self, qr):
if qr.id:
return format_html(
mark_safe('<a href="{}">{}</a>'),
(url := reverse("qr", kwargs=dict(key=qr.key))),
reverse("qr", kwargs=dict(key=qr.key)),
_("Link to Hint Page"),
)
else:
return ""


class HuntAdmin(admin.ModelAdmin):
def save_model(self, request, obj, form, change):
# todo: add warning if admin attempts to change path length or middle locations when hunt has started (will basically re-randomize the hunt (I THINK))

# extras = 1 if obj.starting_location else 0
# extras += 1 if obj.ending_location else 0

if obj.path_length > obj.middle_locations.count():
messages.warning(
request,
"The path length is longer than the amount of locations. "
"If you do not increase middle locations or decrease path length, "
"the path length will be reduced to the amount of locations.",
)
# raise ValidationError(
# "The path length is longer than the amount of locations. Please increase the amount of locations or decrease the path length."
# )
super().save_model(request, obj, form, change)


class UserAdmin(UserAdmin_):
readonly_fields = (
"username",
Expand Down Expand Up @@ -148,5 +168,5 @@ class UserAdmin(UserAdmin_):
admin.site.register(Team, TeamAdmin)
admin.site.register(QrCode, QrCodeAdmin)
admin.site.register(LogicPuzzleHint, LogicPuzzleAdmin)
admin.site.register(Hunt)
admin.site.register(Hunt, HuntAdmin)
admin.site.register(Invite)
29 changes: 22 additions & 7 deletions core/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
import datetime

from django.conf import settings
from core.models import Hunt
from django.utils import timezone


def start(request):
now = timezone.now()
if (hunt := Hunt.current_hunt()) is not None:
event_start = hunt.start
event_end = hunt.end
elif Hunt.next_hunt() is not None:
hunt = Hunt.next_hunt()
event_start = hunt.start
event_end = hunt.end
else:
print("WARNING: No hunt is scheduled")
print("Please add a hunt in the future to the database")
event_start = now + datetime.timedelta(weeks=75)
event_end = event_start + datetime.timedelta(hours=3)

return dict(
START=(start := settings.START),
START_BEFORE=start > datetime.datetime.utcnow(),
START_UNTIL=start - datetime.datetime.utcnow(),
END=(end := settings.END),
END_BEFORE=end > datetime.datetime.utcnow(),
END_UNTIL=end - datetime.datetime.utcnow(),
START=event_start,
START_BEFORE=event_start > now,
START_UNTIL=event_start - now,
END=event_end,
END_BEFORE=event_end > now,
END_UNTIL=event_end - now,
)
Binary file modified core/locale/en_CA/LC_MESSAGES/django.mo
Binary file not shown.
Loading
Loading