Skip to content

Commit

Permalink
Add retroactive checks to validate that ticket_drop_time has not chan…
Browse files Browse the repository at this point in the history
…ged following a ticket being added to a user's cart
  • Loading branch information
julianweng committed Nov 23, 2024
1 parent 1cdb67e commit 57ec73d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion backend/clubs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3192,7 +3192,8 @@ def destroy(self, request, *args, **kwargs):

def partial_update(self, request, *args, **kwargs):
"""
Do not let users modify the ticket drop time if tickets have already been sold.
Do not let club admins modify the ticket drop time
if tickets have already been sold.
"""
event = self.get_object()
if (
Expand Down Expand Up @@ -5237,6 +5238,7 @@ def cart(self, request, *args, **kwargs):
Q(owner__isnull=False)
| Q(holder__isnull=False)
| Q(event__end_time__lt=now)
| Q(event__ticket_drop_time__gt=timezone.now())
).exclude(holder=self.request.user)

# In most cases, we won't need to replace, so exit early
Expand Down Expand Up @@ -5278,6 +5280,7 @@ def cart(self, request, *args, **kwargs):
buyable=True, # should not be triggered as buyable is by ticket class
owner__isnull=True,
holder__isnull=True,
event__ticket_drop_time__lt=timezone.now(),
).exclude(id__in=tickets_in_cart)[: ticket_class["count"]]

num_short = ticket_class["count"] - available_tickets.count()
Expand Down Expand Up @@ -5368,6 +5371,7 @@ def initiate_checkout(self, request, *args, **kwargs):
tickets = cart.tickets.select_for_update(skip_locked=True).filter(
Q(holder__isnull=True) | Q(holder=self.request.user),
owner__isnull=True,
event__ticket_drop_time__lt=timezone.now(),
buyable=True,
)

Expand Down

0 comments on commit 57ec73d

Please sign in to comment.