diff --git a/kfet/templates/kfet/article.html b/kfet/templates/kfet/article.html index 87a8b76a..6b48ddbb 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

+

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

+
+
+ + + + + + + + + + + {% 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 %} +
NomPrixStockEn venteAffichéDernier inventaire
{{ 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' }} +
+
+ + {% endblock %} diff --git a/kfet/views.py b/kfet/views.py index 4c4059e8..5076e5b8 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