create zip to render in html position_list and amount_form.
This commit is contained in:
parent
799b1ba502
commit
e79cba32c1
|
@ -13,7 +13,7 @@
|
||||||
<th scope="col">PRICE p.pce.</th>
|
<th scope="col">PRICE p.pce.</th>
|
||||||
<th scope="col">POSITION PRICE</th>
|
<th scope="col">POSITION PRICE</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for cart_position in cart_position_list %}
|
{% for cart_position, amount_form in cart_position_list_zip %}
|
||||||
<tr class="table_content">
|
<tr class="table_content">
|
||||||
<td scope="col">{{ cart_position.id }}</td>
|
<td scope="col">{{ cart_position.id }}</td>
|
||||||
<td scope="col">{{ cart_position.article.id }}</td>
|
<td scope="col">{{ cart_position.article.id }}</td>
|
||||||
|
|
|
@ -215,8 +215,8 @@ def cart(request):
|
||||||
article_view = True
|
article_view = True
|
||||||
currency_name = "CHF"
|
currency_name = "CHF"
|
||||||
message = ""
|
message = ""
|
||||||
cart_position_list = ""
|
cart_position_list = []
|
||||||
prices_in_cart = []
|
amount_form_list = []
|
||||||
totalprice_list = []
|
totalprice_list = []
|
||||||
total = 0
|
total = 0
|
||||||
user_name = request.user
|
user_name = request.user
|
||||||
|
@ -264,7 +264,7 @@ def cart(request):
|
||||||
checkout_form = checkout_form.cleaned_data['checkout']
|
checkout_form = checkout_form.cleaned_data['checkout']
|
||||||
print('views checkout checkout_form', checkout_form)
|
print('views checkout checkout_form', checkout_form)
|
||||||
if checkout_form is True:
|
if checkout_form is True:
|
||||||
# add to order
|
# todo add to order
|
||||||
order = ''
|
order = ''
|
||||||
# here we handle the normal cart view:
|
# here we handle the normal cart view:
|
||||||
# if the cart_id is set the user has already added items to cart.
|
# if the cart_id is set the user has already added items to cart.
|
||||||
|
@ -301,17 +301,18 @@ def cart(request):
|
||||||
amount_form = CartForm(
|
amount_form = CartForm(
|
||||||
initial={'amount_form': cart_position.amount}
|
initial={'amount_form': cart_position.amount}
|
||||||
)
|
)
|
||||||
|
amount_form_list.append(amount_form)
|
||||||
cart_position_list[idx] = cart_position
|
cart_position_list[idx] = cart_position
|
||||||
|
cart_position_list_zip = zip(cart_position_list, amount_form_list)
|
||||||
|
|
||||||
total = sum(totalprice_list)
|
total = sum(totalprice_list)
|
||||||
|
|
||||||
checkout_form = CheckoutForm()
|
checkout_form = CheckoutForm()
|
||||||
|
|
||||||
return render(request, 'webshop/cart.html',
|
return render(request, 'webshop/cart.html',
|
||||||
{'cart_position_list': cart_position_list,
|
{'cart_position_list_zip': cart_position_list_zip,
|
||||||
'totalprice_list': totalprice_list,
|
'totalprice_list': totalprice_list,
|
||||||
'total': total,
|
'total': total,
|
||||||
'cart_form': cart_form,
|
|
||||||
'currencies_form': currencies_form,
|
'currencies_form': currencies_form,
|
||||||
'amount_form': amount_form,
|
'amount_form': amount_form,
|
||||||
'article_view': article_view,
|
'article_view': article_view,
|
||||||
|
|
Loading…
Reference in New Issue