Fixed a bug concerning the FreeOrderProvider

This commit is contained in:
Raphael Michel
2016-03-10 00:42:58 +01:00
parent 2f72fddd3d
commit 10233071c4
2 changed files with 5 additions and 8 deletions

View File

@@ -162,7 +162,8 @@ class BasePaymentProvider:
"""
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
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``.
"""
@@ -405,9 +406,7 @@ class FreeOrderProvider(BasePaymentProvider):
pass
def payment_is_valid_session(self, request: HttpRequest) -> bool:
return CartPosition.objects.filter(
Q(cart_id=request.session.session_key) & Q(event=request.event)
).aggregate(sum=Sum('price'))['sum'] == 0
return True
@property
def verbose_name(self) -> str:

View File

@@ -151,8 +151,7 @@ class OrderPayDo(EventViewMixin, OrderDetailMixin, TemplateView):
messages.error(request, _('The payment for this order cannot be continued.'))
return redirect(self.get_order_url())
if (not self.payment_provider.payment_is_valid_session(request)
or not self.payment_provider.is_enabled
or not self.payment_provider.is_allowed(request)):
or not self.payment_provider.is_enabled):
messages.error(request, _('The payment information you entered was incomplete.'))
return redirect(self.get_payment_url())
return super().dispatch(request, *args, **kwargs)
@@ -181,8 +180,7 @@ class OrderPayComplete(EventViewMixin, OrderDetailMixin, View):
if not self.order:
raise Http404(_('Unknown order code or not authorized to access this order.'))
if (not self.payment_provider.payment_is_valid_session(request)
or not self.payment_provider.is_enabled
or not self.payment_provider.is_allowed(request)):
or not self.payment_provider.is_enabled):
messages.error(request, _('The payment information you entered was incomplete.'))
return redirect(self.get_payment_url())
return super().dispatch(request, *args, **kwargs)