diff --git a/kfet/templates/kfet/article.html b/kfet/templates/kfet/article.html index 8fb844b7..387806bd 100644 --- a/kfet/templates/kfet/article.html +++ b/kfet/templates/kfet/article.html @@ -6,17 +6,62 @@ {% block content %}
-
-
- Créer un article +
+
+
+
{{ articles|length }}
+
article{{ articles|length|pluralize }}
+
+ +
+
+
+ {% include 'kfet/base_messages.html' %} +
+
+

Liste des articles

+
+ + + + + + + + + + + + + {% for article in articles %} + {% ifchanged article.category %} + + + + {% endifchanged %} + + + + + + + + + {% endfor %} + +
NomPrixStockEn venteDernier inventaire
{{ article.category.name }}
+ + + + {{ article.name }}{{ article.price }}{{ article.stock }}{{ article.is_sold }}{{ article.inventory.0.at }}
+
+
- - {% endblock %} diff --git a/kfet/views.py b/kfet/views.py index 77fd2329..6cdaa83a 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -542,8 +542,12 @@ class CheckoutStatementUpdate(SuccessMessageMixin, UpdateView): # Article - General class ArticleList(ListView): - model = Article - queryset = Article.objects.order_by('category', '-is_sold', 'name') + queryset = (Article.objects + .select_related('category') + .prefetch_related(Prefetch('inventories', + queryset = Inventory.objects.order_by('-at'), + to_attr = 'inventory')) + .order_by('category', '-is_sold', 'name')) template_name = 'kfet/article.html' context_object_name = 'articles'