add total summ
This commit is contained in:
parent
a01d08fded
commit
4f17a85dc7
|
@ -17,12 +17,21 @@
|
||||||
<td scope="col">
|
<td scope="col">
|
||||||
<a href="{% url 'details' article.id %}">
|
<a href="{% url 'details' article.id %}">
|
||||||
{{ article.article.name }}
|
{{ article.article.name }}
|
||||||
</a></td>
|
</a>
|
||||||
|
</td>
|
||||||
<td scope="col">{{ article.article.stock }}</td>
|
<td scope="col">{{ article.article.stock }}</td>
|
||||||
<td scope="col">{{ article.amount }}</td>
|
<td scope="col">{{ article.amount }}</td>
|
||||||
<td scope="col">{{ article.article.price_in_chf }} {{ currency_name }}</td>
|
<td scope="col">
|
||||||
|
{{ article.article.price_in_chf }}
|
||||||
|
{{ currency_name }}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
<tr>
|
||||||
|
<td scope="col" colspan="5" class="text-right">
|
||||||
|
Total: {{ total }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p class="alert">
|
<p class="alert">
|
||||||
|
|
|
@ -9,10 +9,9 @@ from webshop.forms import RegistrationForm, AddToCartForm
|
||||||
|
|
||||||
from currencies.models import ExchangeRate, ExchangeRate_name
|
from currencies.models import ExchangeRate, ExchangeRate_name
|
||||||
from currencies.forms import CurrenciesForm
|
from currencies.forms import CurrenciesForm
|
||||||
|
from decimal import Decimal
|
||||||
|
|
||||||
|
|
||||||
# Create your views here.
|
|
||||||
|
|
||||||
def get_categories():
|
def get_categories():
|
||||||
parent_category_list = Category.objects.filter(parent_category=None)
|
parent_category_list = Category.objects.filter(parent_category=None)
|
||||||
category_list = {}
|
category_list = {}
|
||||||
|
@ -234,6 +233,7 @@ def cart(request):
|
||||||
message = ""
|
message = ""
|
||||||
cart_id = False
|
cart_id = False
|
||||||
articles_list = ""
|
articles_list = ""
|
||||||
|
total = Decimal(0)
|
||||||
|
|
||||||
if not 'currency' in request.session:
|
if not 'currency' in request.session:
|
||||||
request.session['currency'] = None
|
request.session['currency'] = None
|
||||||
|
@ -262,13 +262,17 @@ def cart(request):
|
||||||
currency, article.article.price_in_chf)
|
currency, article.article.price_in_chf)
|
||||||
articles_list[idx] = article
|
articles_list[idx] = article
|
||||||
currency_name = ExchangeRate_name.objects.get(id=currency)
|
currency_name = ExchangeRate_name.objects.get(id=currency)
|
||||||
article.price_in_chf = rate.exchange(currency, article.price_in_chf)
|
article.price_in_chf = rate.exchange(
|
||||||
|
currency,
|
||||||
|
article.price_in_chf)
|
||||||
|
total += article.price_in_chf
|
||||||
else:
|
else:
|
||||||
articles = CartPosition.objects.filter(cart=cart_id)
|
articles = CartPosition.objects.filter(cart=cart_id)
|
||||||
articles_list = list(articles)
|
articles_list = list(articles)
|
||||||
|
|
||||||
return render(request, 'webshop/cart.html',
|
return render(request, 'webshop/cart.html',
|
||||||
{'articles_list': articles_list,
|
{'articles_list': articles_list,
|
||||||
|
'total': total,
|
||||||
'currencies_form': currencies_form,
|
'currencies_form': currencies_form,
|
||||||
'article_view': article_view,
|
'article_view': article_view,
|
||||||
'currency_name': currency_name,
|
'currency_name': currency_name,
|
||||||
|
|
Loading…
Reference in New Issue