forked from CGM_Public/pretix_original
Fixed a bug concerning the FreeOrderProvider
This commit is contained in:
@@ -162,7 +162,8 @@ class BasePaymentProvider:
|
|||||||
"""
|
"""
|
||||||
You can use this method to disable this payment provider for certain groups
|
You can use this method to disable this payment provider for certain groups
|
||||||
of users, products or other criteria. If this method returns ``False``, the
|
of users, products or other criteria. If this method returns ``False``, the
|
||||||
user will not be able to select this payment method.
|
user will not be able to select this payment method. This will only be called
|
||||||
|
during checkout, not on retrying.
|
||||||
|
|
||||||
The default implementation always returns ``True``.
|
The default implementation always returns ``True``.
|
||||||
"""
|
"""
|
||||||
@@ -405,9 +406,7 @@ class FreeOrderProvider(BasePaymentProvider):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def payment_is_valid_session(self, request: HttpRequest) -> bool:
|
def payment_is_valid_session(self, request: HttpRequest) -> bool:
|
||||||
return CartPosition.objects.filter(
|
return True
|
||||||
Q(cart_id=request.session.session_key) & Q(event=request.event)
|
|
||||||
).aggregate(sum=Sum('price'))['sum'] == 0
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def verbose_name(self) -> str:
|
def verbose_name(self) -> str:
|
||||||
|
|||||||
@@ -151,8 +151,7 @@ class OrderPayDo(EventViewMixin, OrderDetailMixin, TemplateView):
|
|||||||
messages.error(request, _('The payment for this order cannot be continued.'))
|
messages.error(request, _('The payment for this order cannot be continued.'))
|
||||||
return redirect(self.get_order_url())
|
return redirect(self.get_order_url())
|
||||||
if (not self.payment_provider.payment_is_valid_session(request)
|
if (not self.payment_provider.payment_is_valid_session(request)
|
||||||
or not self.payment_provider.is_enabled
|
or not self.payment_provider.is_enabled):
|
||||||
or not self.payment_provider.is_allowed(request)):
|
|
||||||
messages.error(request, _('The payment information you entered was incomplete.'))
|
messages.error(request, _('The payment information you entered was incomplete.'))
|
||||||
return redirect(self.get_payment_url())
|
return redirect(self.get_payment_url())
|
||||||
return super().dispatch(request, *args, **kwargs)
|
return super().dispatch(request, *args, **kwargs)
|
||||||
@@ -181,8 +180,7 @@ class OrderPayComplete(EventViewMixin, OrderDetailMixin, View):
|
|||||||
if not self.order:
|
if not self.order:
|
||||||
raise Http404(_('Unknown order code or not authorized to access this order.'))
|
raise Http404(_('Unknown order code or not authorized to access this order.'))
|
||||||
if (not self.payment_provider.payment_is_valid_session(request)
|
if (not self.payment_provider.payment_is_valid_session(request)
|
||||||
or not self.payment_provider.is_enabled
|
or not self.payment_provider.is_enabled):
|
||||||
or not self.payment_provider.is_allowed(request)):
|
|
||||||
messages.error(request, _('The payment information you entered was incomplete.'))
|
messages.error(request, _('The payment information you entered was incomplete.'))
|
||||||
return redirect(self.get_payment_url())
|
return redirect(self.get_payment_url())
|
||||||
return super().dispatch(request, *args, **kwargs)
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|||||||
Reference in New Issue
Block a user