From cc27e4d96427c0cf69d6b58f7b68109d08856c4f Mon Sep 17 00:00:00 2001 From: Qwann Date: Thu, 22 Mar 2018 15:25:03 +0100 Subject: [PATCH 1/3] show not sold article in a different list --- kfet/templates/kfet/article.html | 46 ++++++++++++++++++++++++++++++-- kfet/views.py | 8 ++++++ 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/kfet/templates/kfet/article.html b/kfet/templates/kfet/article.html index 7966e797..8cec4279 100644 --- a/kfet/templates/kfet/article.html +++ b/kfet/templates/kfet/article.html @@ -7,8 +7,11 @@ @@ -25,6 +28,7 @@ {% endblock %} {% block main %} +

Article{{ articles|length|pluralize}} en vente

@@ -60,6 +64,44 @@
+ +

Articles non vendus

+

Article{{ not_sold_articles|length|pluralize }} non vendu{{ nots_sold_article|length|pluralize }}

+
+ + + + + + + + + + + + + {% for article in not_sold_articles %} + {% ifchanged article.category %} + + + + {% endifchanged %} + + + + + + + + + {% endfor %} + +
NomPrixStockEn venteAffichéDernier inventaire
{{ article.category.name }}
+ + {{ article.name }} + + {{ article.price }}€{{ article.stock }}{{ article.is_sold | yesno:"En vente,Non vendu"}}{{ article.hidden | yesno:"Caché,Affiché" }}{{ article.inventory.0.at }}
+
{% endblock %} diff --git a/kfet/views.py b/kfet/views.py index 2b69684d..63bd280c 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -706,6 +706,14 @@ class ArticleList(ListView): ) template_name = 'kfet/article.html' context_object_name = 'articles' + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + articles = context[self.context_object_name] + context['nb_articles'] = len(articles) + context[self.context_object_name] = articles.filter(is_sold=True) + context['not_sold_articles'] = articles.filter(is_sold=False) + return context # Article - Create From 158b19778b19daeba35413027ba30b518d1110a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sat, 7 Apr 2018 14:20:41 +0200 Subject: [PATCH 2/3] also sort the unsold table --- kfet/templates/kfet/article.html | 61 +++++++++++++++++++------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/kfet/templates/kfet/article.html b/kfet/templates/kfet/article.html index 002abadd..b1f173c6 100644 --- a/kfet/templates/kfet/article.html +++ b/kfet/templates/kfet/article.html @@ -79,38 +79,49 @@

Articles non vendus

Article{{ not_sold_articles|length|pluralize }} non vendu{{ nots_sold_article|length|pluralize }}

- +
- - - + + + - - {% for article in not_sold_articles %} - {% ifchanged article.category %} - - - - {% endifchanged %} - - - - - - - - - {% endfor %} - + {% regroup not_sold_articles by category as not_sold_category_list %} + + {% for category in not_sold_category_list %} + + + + + + + {% for article in category.list %} + + + + + + + {% with last_inventory=article.inventory.0 %} + + {% endwith %} + + {% endfor %} + + {% endfor %}
Nom Prix StockEn venteAffichéDernier inventaireEn venteAffichéDernier inventaire
{{ article.category.name }}
- - {{ article.name }} - - {{ article.price }}€{{ article.stock }}{{ article.is_sold | yesno:"En vente,Non vendu"}}{{ article.hidden | yesno:"Caché,Affiché" }}{{ article.inventory.0.at }}
{{ category.grouper }}
+ + {{ article.name }} + + {{ article.price }}€{{ article.stock }}{{ article.is_sold | yesno:"En vente,Non vendu"}}{{ article.hidden | yesno:"Caché,Affiché" }} + {{ last_inventory.at|date:'d/m/Y H:i' }} +
From 53a4c78903d6b09611aaa9eb10ee9d36a05d8cf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sat, 7 Apr 2018 14:21:07 +0200 Subject: [PATCH 3/3] Remove duplicate line --- kfet/templates/kfet/article.html | 1 - 1 file changed, 1 deletion(-) diff --git a/kfet/templates/kfet/article.html b/kfet/templates/kfet/article.html index b1f173c6..6b48ddbb 100644 --- a/kfet/templates/kfet/article.html +++ b/kfet/templates/kfet/article.html @@ -76,7 +76,6 @@ -

Articles non vendus

Article{{ not_sold_articles|length|pluralize }} non vendu{{ nots_sold_article|length|pluralize }}