push form hack
This commit is contained in:
parent
29e99e49c0
commit
eacdbd3f30
|
@ -68,16 +68,19 @@ class AddToCartForm(forms.Form):
|
||||||
|
|
||||||
|
|
||||||
class CartForm(forms.Form):
|
class CartForm(forms.Form):
|
||||||
print('CartForm')
|
amount_field = forms.IntegerField(
|
||||||
def ChangeAmount(self, _cart_id, _article_id):
|
label='pce',
|
||||||
|
help_text='Enter a Value between 1 and 99.')
|
||||||
|
|
||||||
|
def change_amount(self, article):
|
||||||
print('CartForm.ChangeAmount')
|
print('CartForm.ChangeAmount')
|
||||||
article = CartPosition.objects.get(cart=_cart_id, article=_article_id)
|
position = CartPosition.objects.get(article=article)
|
||||||
amountfield = forms.IntegerField(
|
self.amount_field = forms.IntegerField(
|
||||||
label='pce',
|
label='pce',
|
||||||
help_text='Enter a Value between 1 and 99.',
|
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):
|
class CheckoutForm(forms.Form):
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
<td scope="col">{{ cart_position.article.stock }}</td>
|
<td scope="col">{{ cart_position.article.stock }}</td>
|
||||||
<td scope="col">
|
<td scope="col">
|
||||||
<form id="amountfield" action="" method="POST" novalidate>
|
<form id="amountfield" action="" method="POST" novalidate>
|
||||||
{{ CartForm }}
|
{{ cart_form }}
|
||||||
<input type="submit" value="change" />
|
<input type="submit" value="change" />
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -193,6 +193,7 @@ def registration(request):
|
||||||
def cart(request):
|
def cart(request):
|
||||||
category_list = get_categories()
|
category_list = get_categories()
|
||||||
currencies_form = CurrenciesForm
|
currencies_form = CurrenciesForm
|
||||||
|
cart_form = CartForm
|
||||||
rate = ExchangeRate
|
rate = ExchangeRate
|
||||||
article_view = True
|
article_view = True
|
||||||
currency_name = "CHF"
|
currency_name = "CHF"
|
||||||
|
@ -274,12 +275,11 @@ def cart(request):
|
||||||
# get currencyname to display:
|
# get currencyname to display:
|
||||||
currency_name = ExchangeRate_name.objects.get(id=currency)
|
currency_name = ExchangeRate_name.objects.get(id=currency)
|
||||||
# get exchange_rate multiplyed:
|
# get exchange_rate multiplyed:
|
||||||
cart_position.price_in_chf = rate.exchange(
|
cart_position.article.price_in_chf = rate.exchange(
|
||||||
currency,
|
currency,
|
||||||
article.price_in_chf)
|
cart_position.article.price_in_chf)
|
||||||
amount = CartForm.ChangeAmount(request.POST,
|
amount = cart_form.change_amount(request.POST,
|
||||||
cart_id,
|
cart_position.article)
|
||||||
cart_position.article.id)
|
|
||||||
totalprice_list.append(cart_position.position_price)
|
totalprice_list.append(cart_position.position_price)
|
||||||
cart_position_list[idx] = cart_position
|
cart_position_list[idx] = cart_position
|
||||||
|
|
||||||
|
@ -289,6 +289,7 @@ def cart(request):
|
||||||
{'cart_position_list': cart_position_list,
|
{'cart_position_list': cart_position_list,
|
||||||
'totalprice_list': totalprice_list,
|
'totalprice_list': totalprice_list,
|
||||||
'total': total,
|
'total': total,
|
||||||
|
'cart_form': cart_form,
|
||||||
'currencies_form': currencies_form,
|
'currencies_form': currencies_form,
|
||||||
'checkout_form': checkout_form,
|
'checkout_form': checkout_form,
|
||||||
'article_view': article_view,
|
'article_view': article_view,
|
||||||
|
|
Loading…
Reference in New Issue