From 1fe10e218506c5ce14fcb7c500768fb4a1b48a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ho=CC=88rler?= Date: Sun, 4 Feb 2018 18:32:54 +0100 Subject: [PATCH] commit for andreas --- django/didgeridoo/webshop/models.py | 3 +- .../templates/webshop/article_details.html | 14 +++-- .../webshop/templates/webshop/cart.html | 9 ++++ .../webshop/templates/webshop/nav.html | 2 +- django/didgeridoo/webshop/urls.py | 3 ++ django/didgeridoo/webshop/views.py | 52 ++++++++++++++++++- 6 files changed, 73 insertions(+), 10 deletions(-) create mode 100644 django/didgeridoo/webshop/templates/webshop/cart.html diff --git a/django/didgeridoo/webshop/models.py b/django/didgeridoo/webshop/models.py index c41f4f5..1d966f9 100644 --- a/django/didgeridoo/webshop/models.py +++ b/django/didgeridoo/webshop/models.py @@ -100,9 +100,8 @@ class OrderPosition(models.Model): class ShoppingCart(models.Model): """ Cart to User Relationships """ - name = models.CharField(max_length=200) + name = models.CharField(max_length=200, null=True) user = models.ForeignKey(User, on_delete=models.CASCADE) - article = models.ManyToManyField(Article) def __str__(self): return self.name diff --git a/django/didgeridoo/webshop/templates/webshop/article_details.html b/django/didgeridoo/webshop/templates/webshop/article_details.html index eda8ff6..a16a642 100644 --- a/django/didgeridoo/webshop/templates/webshop/article_details.html +++ b/django/didgeridoo/webshop/templates/webshop/article_details.html @@ -6,11 +6,15 @@

Stock: {{ article.stock }}

Status: {{ article.status }}

Price: {{ article.price_in_chf }} {{ currency_name }}

-
- {{ amount.as_p }} - - {% csrf_token %} -
+ {% if user.is_authenticated %} +
+ {{ amount.as_p }} + + {% csrf_token %} +
+ {% else %} +

please login to fill your basket...

+ {% endif %} {% for picture in picture_list %}

{% endfor %} diff --git a/django/didgeridoo/webshop/templates/webshop/cart.html b/django/didgeridoo/webshop/templates/webshop/cart.html new file mode 100644 index 0000000..bf1f238 --- /dev/null +++ b/django/didgeridoo/webshop/templates/webshop/cart.html @@ -0,0 +1,9 @@ +{% extends "webshop/base.html" %} +{% block section_title %}

Cart

{% endblock %} +{% block content %} +

List of Items in your Shopping Cart:

+

{{ article.description }}

+

in Stock: {{ article.stock }}

+

Amount you whant: {{ article.amount }}

+

Price: {{ article.price_in_chf }} {{ currency_name }}

+{% endblock %} diff --git a/django/didgeridoo/webshop/templates/webshop/nav.html b/django/didgeridoo/webshop/templates/webshop/nav.html index d5c22c9..8aa7f44 100644 --- a/django/didgeridoo/webshop/templates/webshop/nav.html +++ b/django/didgeridoo/webshop/templates/webshop/nav.html @@ -6,7 +6,7 @@ HOME