From c30a44f11765884dc13edca845c9093958d7e882 Mon Sep 17 00:00:00 2001 From: alice Date: Tue, 29 Dec 2020 17:12:55 +0100 Subject: [PATCH] limit open payments per user --- payments/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/payments/views.py b/payments/views.py index 4a797bb..07aff5f 100644 --- a/payments/views.py +++ b/payments/views.py @@ -27,6 +27,10 @@ def new(request): if request.method != 'POST': return redirect('account:index') + if Payment.objects.filter(user=request.user, status='new').count() > 10: + messages.error(request, "Too many open payments.") + return redirect('account:index') + form = NewPaymentForm(request.POST) if not form.is_valid():