Fix voucher redemption with time machine [Z#23159226] (#4352)

Redeeming a voucher failed if current time is outside the booking period and the shop was accessed via time machine.
This commit is contained in:
Mira
2024-07-30 09:14:36 +02:00
committed by GitHub
parent 58b803539b
commit 858a448db5

View File

@@ -653,10 +653,11 @@ class RedeemView(NoSearchIndexViewMixin, EventViewMixin, CartMixin, TemplateView
context['show_cart'] = context['cart']['positions'] context['show_cart'] = context['cart']['positions']
return render(request, 'pretixpresale/event/voucher_form.html', context) return render(request, 'pretixpresale/event/voucher_form.html', context)
if request.event.presale_has_ended or (request.event.presale_end and now() > request.event.presale_end): if request.event.presale_has_ended or (
request.event.presale_end and time_machine_now() > request.event.presale_end):
err = error_messages['ended'] err = error_messages['ended']
elif not request.event.presale_is_running or ( elif not request.event.presale_is_running or (
request.event.presale_start and now() < request.event.presale_start): request.event.presale_start and time_machine_now() < request.event.presale_start):
err = error_messages['not_started'] err = error_messages['not_started']
self.subevent = None self.subevent = None