diff --git a/django/didgeridoo/webshop/forms.py b/django/didgeridoo/webshop/forms.py index 46145a7..9c31a3b 100644 --- a/django/didgeridoo/webshop/forms.py +++ b/django/didgeridoo/webshop/forms.py @@ -69,9 +69,9 @@ class AddToCartForm(forms.Form): class CartForm(forms.Form): print('CartForm') - def ChangeAmount(self, _article_id): + def ChangeAmount(self, _cart_id, _article_id): print('CartForm.ChangeAmount') - article = CartPosition.objects.filter(pk=_article_id) + article = CartPosition.objects.get(cart=_cart_id, article=_article_id) amountfield = forms.IntegerField( label='pce', help_text='Enter a Value between 1 and 99.', diff --git a/django/didgeridoo/webshop/models.py b/django/didgeridoo/webshop/models.py index 9551f84..111f346 100644 --- a/django/didgeridoo/webshop/models.py +++ b/django/didgeridoo/webshop/models.py @@ -104,7 +104,7 @@ class ShoppingCart(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) def __str__(self): - return self.name + return str(self.id) class CartPosition(models.Model): diff --git a/django/didgeridoo/webshop/templates/webshop/cart.html b/django/didgeridoo/webshop/templates/webshop/cart.html index 83c69e0..334f5a6 100644 --- a/django/didgeridoo/webshop/templates/webshop/cart.html +++ b/django/didgeridoo/webshop/templates/webshop/cart.html @@ -2,7 +2,7 @@ {% block section_title %}
POS. | @@ -13,16 +13,16 @@PRICE p.pce. | POSITION PRICE | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
{{ article.id }} | -{{ article.article.id }} | +{{ cart_position.id }} | +{{ cart_position.article.id }} | - - {{ article.article.name }} + + {{ cart_position.article.name }} | -{{ article.article.stock }} | +{{ cart_position.article.stock }} | - {{ article.article.price_in_chf }} + {{ cart_position.article.price_in_chf }} {{ currency_name }} | -{{ article.position_price }} {{ currency_name }} | +{{ cart_position.position_price }} {{ currency_name }} | |
diff --git a/django/didgeridoo/webshop/templates/webshop/checkout.html b/django/didgeridoo/webshop/templates/webshop/checkout.html
new file mode 100644
index 0000000..e81dae1
--- /dev/null
+++ b/django/didgeridoo/webshop/templates/webshop/checkout.html
@@ -0,0 +1,60 @@
+{% extends "webshop/base.html" %}
+{% block section_title %}
+
+ This cart seams to lack some Items.
+ Go get some in the store!
+
+
+
+ {{ message }}
+
+ Cart
{% endblock %}
+{% block content %}
+ List of Items in your Shopping Cart:
+ {% if articles_list %}
+
+
+
+ {% else %}
+
+
+ {% for article in articles_list %}
+ POS.
+ ART#
+ NAME
+ STOCK
+ AMOUNT
+ PRICE p.pce.
+ POSITION PRICE
+
+
+ {% endfor %}
+ {{ article.id }}
+ {{ article.article.id }}
+
+
+ {{ article.article.name }}
+
+
+ {{ article.article.stock }}
+
+ {{ article.amount }}
+
+
+ {{ article.article.price_in_chf }}
+ {{ currency_name }}
+
+ {{ article.position_price }} {{ currency_name }}
+
+
+
+ Total: {{ total }} {{ currency_name }}
+
+