diff --git a/backend/clubs/views.py b/backend/clubs/views.py index 07e02d255..3417952a9 100644 --- a/backend/clubs/views.py +++ b/backend/clubs/views.py @@ -2241,6 +2241,12 @@ def cart(self, request, *args, **kwargs): - $ref: "#/components/schemas/Ticket" --- """ + # Update holding status for all held tickets + held_tickets = Ticket.objects.filter(held=True).all() + for ticket in held_tickets: + if ticket.holding_expiration <= timezone.now(): + ticket.held = False + ticket.save() type = request.data.get("type") count = request.data.get("count") event = Event.objects.get(id=self.get_object().id) @@ -2282,12 +2288,12 @@ def validate_cart(self, request, *args, **kwargs): - $ref: "#/components/schemas/Ticket" --- """ - # Update holding expirations for all tickets - for ticket in Ticket.objects.all(): - if ticket.holding_expiration: - if ticket.holding_expiration <= timezone.now(): - ticket.held = False - ticket.save() + # Update holding status for all held tickets + held_tickets = Ticket.objects.filter(held=True).all() + for ticket in held_tickets: + if ticket.holding_expiration <= timezone.now(): + ticket.held = False + ticket.save() cart = Cart.objects.filter(owner=self.request.user).first()