From cf5462b901fa6b81778273fba0e0ddbd1e5816ae Mon Sep 17 00:00:00 2001 From: Martin Quarda Date: Mon, 14 Oct 2024 15:27:30 +0200 Subject: [PATCH] mandatory select delivery --- alkatorapi/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/alkatorapi/views.py b/alkatorapi/views.py index 5e05b2b..8ca7a63 100644 --- a/alkatorapi/views.py +++ b/alkatorapi/views.py @@ -402,6 +402,9 @@ def cart_buy(request): if cp.quantity > cp.product.quantity: return HttpResponse('{"status": "failed", "reason": "Nemáme dostatek ' + cp.product.name + ' na skladě!"}', status=400, content_type='application/json') + if not cart.address: + return HttpResponse('{"status": "failed", "reason": "Je potřeba vybrat výběrní místo!"}', status=400, content_type='application/json') + invoice = Invoice( user=user, address=cart.address, @@ -423,7 +426,7 @@ def cart_buy(request): total_price += cp.quantity * cp.product.price ip.save() - if total_price <= 0: + if total_price <= 79: return HttpResponse('{"status": "failed", "reason": "Prosím přidejte svoje položky do košíku!"}', status=400, content_type='application/json') payment_data = {