OrderGo: Fix crash if invoice number matches different prefixes (PRETIXEU-64T)

This commit is contained in:
Raphael Michel
2022-02-23 13:07:15 +01:00
parent cc8282bef1
commit 67ba1f81e4

View File

@@ -2215,12 +2215,10 @@ class OrderGo(EventPermissionRequiredMixin, View):
return redirect('control:event.order', event=request.event.slug, organizer=request.event.organizer.slug,
code=order.code)
except Order.DoesNotExist:
try:
i = self.request.event.invoices.get(Q(invoice_no=code) | Q(full_invoice_no=code))
i = self.request.event.invoices.filter(Q(invoice_no=code) | Q(full_invoice_no=code)).first()
if i:
return redirect('control:event.order', event=request.event.slug, organizer=request.event.organizer.slug,
code=i.order.code)
except Invoice.DoesNotExist:
pass
messages.error(request, _('There is no order with the given order code.'))
return redirect('control:event.orders', event=request.event.slug, organizer=request.event.organizer.slug)