diff --git a/django/didgeridoo/webshop/forms.py b/django/didgeridoo/webshop/forms.py
index 9c31a3b..925929a 100644
--- a/django/didgeridoo/webshop/forms.py
+++ b/django/didgeridoo/webshop/forms.py
@@ -68,16 +68,19 @@ class AddToCartForm(forms.Form):
class CartForm(forms.Form):
- print('CartForm')
- def ChangeAmount(self, _cart_id, _article_id):
+ amount_field = forms.IntegerField(
+ label='pce',
+ help_text='Enter a Value between 1 and 99.')
+
+ def change_amount(self, article):
print('CartForm.ChangeAmount')
- article = CartPosition.objects.get(cart=_cart_id, article=_article_id)
- amountfield = forms.IntegerField(
+ position = CartPosition.objects.get(article=article)
+ self.amount_field = forms.IntegerField(
label='pce',
help_text='Enter a Value between 1 and 99.',
- initial=article.amount
+ initial=position.amount
)
- return amountfield
+ return self.amount_field
class CheckoutForm(forms.Form):
diff --git a/django/didgeridoo/webshop/templates/webshop/cart.html b/django/didgeridoo/webshop/templates/webshop/cart.html
index 334f5a6..78085d4 100644
--- a/django/didgeridoo/webshop/templates/webshop/cart.html
+++ b/django/didgeridoo/webshop/templates/webshop/cart.html
@@ -25,7 +25,7 @@
{{ cart_position.article.stock }} |
diff --git a/django/didgeridoo/webshop/views.py b/django/didgeridoo/webshop/views.py
index 87becee..9313c73 100644
--- a/django/didgeridoo/webshop/views.py
+++ b/django/didgeridoo/webshop/views.py
@@ -193,6 +193,7 @@ def registration(request):
def cart(request):
category_list = get_categories()
currencies_form = CurrenciesForm
+ cart_form = CartForm
rate = ExchangeRate
article_view = True
currency_name = "CHF"
@@ -274,12 +275,11 @@ def cart(request):
# get currencyname to display:
currency_name = ExchangeRate_name.objects.get(id=currency)
# get exchange_rate multiplyed:
- cart_position.price_in_chf = rate.exchange(
+ cart_position.article.price_in_chf = rate.exchange(
currency,
- article.price_in_chf)
- amount = CartForm.ChangeAmount(request.POST,
- cart_id,
- cart_position.article.id)
+ cart_position.article.price_in_chf)
+ amount = cart_form.change_amount(request.POST,
+ cart_position.article)
totalprice_list.append(cart_position.position_price)
cart_position_list[idx] = cart_position
@@ -289,6 +289,7 @@ def cart(request):
{'cart_position_list': cart_position_list,
'totalprice_list': totalprice_list,
'total': total,
+ 'cart_form': cart_form,
'currencies_form': currencies_form,
'checkout_form': checkout_form,
'article_view': article_view,
|