diff --git a/django/didgeridoo/webshop/forms.py b/django/didgeridoo/webshop/forms.py index e762e45..7aada1f 100644 --- a/django/didgeridoo/webshop/forms.py +++ b/django/didgeridoo/webshop/forms.py @@ -74,7 +74,6 @@ class CartForm(forms.Form): class CheckoutForm(forms.Form): - checkout = forms.BooleanField( required=True, label='Yes. I have read the General Terms and Conditions.') diff --git a/django/didgeridoo/webshop/templates/webshop/checkout.html b/django/didgeridoo/webshop/templates/webshop/checkout.html index 1dabb2b..f1cad54 100644 --- a/django/didgeridoo/webshop/templates/webshop/checkout.html +++ b/django/didgeridoo/webshop/templates/webshop/checkout.html @@ -60,7 +60,7 @@ -
+ {% csrf_token %} {{ checkout_form.as_p }} diff --git a/django/didgeridoo/webshop/views.py b/django/didgeridoo/webshop/views.py index 7f047d9..f55a0fd 100644 --- a/django/didgeridoo/webshop/views.py +++ b/django/didgeridoo/webshop/views.py @@ -11,7 +11,8 @@ from webshop.models import (Article, Picture, CartPosition, ShoppingCart, - Order) + Order, + OrderStatus) from webshop.forms import (RegistrationForm, AddToCartForm, CartForm, @@ -329,17 +330,19 @@ def checkout(request): exchange_rate = ExchangeRate.objects.filter(name=currency).latest('date') # Here we handle all POST Operations: if request.method == 'POST': - print('checkout post') + print('checkout post', request.POST) # here we react to a change of amount per item in the Cart: - if 'checkout_form' in request.POST: + if 'checkout' in request.POST: print('checkout post request.POST = checkout_form') - checkout_form = CartForm(request.POST) + checkout_form = CheckoutForm(request.POST) if checkout_form.is_valid(): - print('checkout post valid') + orderstatus = OrderStatus.objects.get(name='ordered') + print('checkout post valid orderstatus', orderstatus, + 'exchange_rate_id:', exchange_rate_id) order, created_order = Order.objects.get_or_create( user=request.user, - defaults={'status': 1, - 'exchange_rate': exchange_rate.id, + defaults={'status': orderstatus, + 'exchange_rate': exchange_rate, } ) print('order', order, 'created:', created_order) @@ -385,8 +388,6 @@ def checkout(request): {'cart_position_list': cart_position_list, 'totalprice_list': totalprice_list, 'total': total, - 'currencies_form': currencies_form, - 'amount_form': amount_form, 'checkout_form': checkout_form, 'currency_name': currency_name, 'article_view': article_view,