Détails commande

- 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`
This commit is contained in:
Aurélien Delobelle 2016-08-30 17:07:51 +02:00
parent 72a4f5563e
commit 3c5f8c49aa
2 changed files with 60 additions and 6 deletions

View file

@ -5,10 +5,63 @@
{% block content %}
<p>
Créée le {{ order.at }} pour {{ order.supplier.name }}
</p>
<textarea>{{ mail }}</textarea>
<div class="row">
<div class="col-sm-4 col-md-3 col-content-left">
<div class="content-left">
<div class="content-left-top">
<div class="line"><b>Créée le:</b> {{ order.at }}</div>
<div class="line"><b>Fournisseur:</b> {{ order.supplier.name }}</div>
</div>
</div>
</div>
<div class="col-sm-8 col-md-9 col-content-right">
{% include 'kfet/base_messages.html' %}
<div class="content-right">
<div class="content-right-block">
<h2>Détails</h2>
<div>
<table class="table">
<thead>
<tr>
<td>Article</td>
<td>Commandé</td>
<td>Commandé (#box)</td>
<td>Reçu</td>
</tr>
</thead>
<tbody>
{% for orderart in orderarts %}
{% ifchanged orderart.article.category %}
<tr>
<td colspan="4">{{ orderart.article.category.name }}</td>
</tr>
{% endifchanged %}
<tr>
<td>{{ orderart.article.name }}</td>
<td>{{ orderart.quantity_ordered }}</td>
<td>
{% if orderart.article.box_capacity %}
{# c'est une division ! #}
{% widthratio orderart.quantity_ordered orderart.article.box_capacity 1 %}
{% endif %}
</td>
<td>
{{ orderart.quantity_received|default_if_none:'' }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="content-right-block">
<h2>Mail</h2>
<div>
<textarea>{{ mail }}</textarea>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -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