From 3c5f8c49aaa50f4ef5fadcc7a44a28bd45d53549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Delobelle?= Date: Tue, 30 Aug 2016 17:07:51 +0200 Subject: [PATCH] =?UTF-8?q?D=C3=A9tails=20commande?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Ajout du détails d'une commande sur sa page - Réorganisation de la vue `order.read` - Optimisation queries DB avec select_related sur `OrderList` --- kfet/templates/kfet/order_read.html | 63 ++++++++++++++++++++++++++--- kfet/views.py | 3 +- 2 files changed, 60 insertions(+), 6 deletions(-) diff --git a/kfet/templates/kfet/order_read.html b/kfet/templates/kfet/order_read.html index beffd359..26bdbbdc 100644 --- a/kfet/templates/kfet/order_read.html +++ b/kfet/templates/kfet/order_read.html @@ -5,10 +5,63 @@ {% block content %} -

-Créée le {{ order.at }} pour {{ order.supplier.name }} -

- - +
+
+
+
+
Créée le: {{ order.at }}
+
Fournisseur: {{ order.supplier.name }}
+
+
+
+
+ {% include 'kfet/base_messages.html' %} +
+
+

Détails

+
+ + + + + + + + + + + {% for orderart in orderarts %} + {% ifchanged orderart.article.category %} + + + + {% endifchanged %} + + + + + + + {% endfor %} + +
ArticleCommandéCommandé (#box)Reçu
{{ orderart.article.category.name }}
{{ orderart.article.name }}{{ orderart.quantity_ordered }} + {% if orderart.article.box_capacity %} + {# c'est une division ! #} + {% widthratio orderart.quantity_ordered orderart.article.box_capacity 1 %} + {% endif %} + + {{ orderart.quantity_received|default_if_none:'' }} +
+
+
+
+

Mail

+
+ +
+
+
+
+
{% endblock %} diff --git a/kfet/views.py b/kfet/views.py index 116c1f3b..7169c392 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -1356,7 +1356,7 @@ def inventory_create(request): # ----- class OrderList(ListView): - model = Order + queryset = Order.objects.select_related('supplier', 'inventory') template_name = 'kfet/order.html' context_object_name = 'orders' @@ -1507,6 +1507,7 @@ class OrderRead(DetailView): .filter(order=self.object) .order_by('article__category__name', 'article__name') ) + context['orderarts'] = orderarticles mail = ("Bonjour,\n\nNous voudrions pour le ##DATE## à la K-Fêt de " "l'ENS Ulm :") category = 0