Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLovesDoggo committed Dec 5, 2023
2 parents ff3cddb + 754ec2a commit 07ef442
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
1 change: 0 additions & 1 deletion core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ def join(self, user: User):
if self.is_full:
raise IndexError("Team is full")
self.members.add(user)


def invites(self):
return Invite.objects.filter(team=self)
Expand Down
16 changes: 8 additions & 8 deletions core/views/qr.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ def wrapped(*args, **kwargs):

return wrapped


def block_if_current_hunt(f):
@wraps(f)
def wrapped(*args, **kwargs):
request = args[0]
hunt_ = Hunt.current_hunt()
if request.user.is_impersonate or request.user.is_superuser: # if the user is an admin or is being impersonated (by a SU), allow them to create a team
return f(
*args, **kwargs
)
if (
request.user.is_impersonate or request.user.is_superuser
): # if the user is an admin or is being impersonated (by a SU), allow them to create a team
return f(*args, **kwargs)
if hunt_ is not None and not hunt_.allow_creation_post_start:
messages.error(
request,
Expand All @@ -63,12 +64,11 @@ def wrapped(*args, **kwargs):
),
)
return redirect(reverse("index"))
return f(
*args, **kwargs
)

return f(*args, **kwargs)

return wrapped


def during_hunt(f):
"""
Decorator for views that checks that the hunt is currently active.
Expand Down
8 changes: 6 additions & 2 deletions core/views/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,13 @@ def solo(q: HttpRequest):
@team_required
@upcoming_hunt_required # redundant
def invite(q):
invites = Invite.objects.filter(team=q.user.current_team).values_list("code", flat=True)
invites = Invite.objects.filter(team=q.user.current_team).values_list(
"code", flat=True
)
if invites.count() == 0:
print("No invites found, creating one")
Invite.objects.create(team=q.user.current_team, code=generate_invite_code(), invites=0)
Invite.objects.create(
team=q.user.current_team, code=generate_invite_code(), invites=0
)
return invite(q)
return render(q, "core/team_invite.html", context=dict(invites=invites))

0 comments on commit 07ef442

Please sign in to comment.