{% if item.get_remaining_nb is not null %}
{% if item.get_remaining_nb == 0 %}Produit épuisé
@@ -88,6 +88,10 @@
{% endif %}{% endif %}
{% endfor %}
+
+
+
Total : 0 €
+
@@ -104,7 +108,8 @@
{{ item.price }} €
{% endfor %}
+
Total : 0 €
{% if error_message %}
{{ error_message }}
{% endif %}
@@ -131,7 +137,7 @@
-
+
@@ -141,9 +147,36 @@
+ Commander
+
+
Total : 0 €
{% endif %}
-{% endblock %}
\ No newline at end of file
+{% endblock %}
+
+
\ No newline at end of file
diff --git a/la_chariotte/order/views/grouped_order.py b/la_chariotte/order/views/grouped_order.py
index 3568843..c87076e 100644
--- a/la_chariotte/order/views/grouped_order.py
+++ b/la_chariotte/order/views/grouped_order.py
@@ -1,8 +1,10 @@
import csv
+import json
from io import BytesIO
from django import http
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
+from django.core.serializers.json import DjangoJSONEncoder
from django.shortcuts import get_object_or_404
from django.template.loader import get_template
from django.urls import reverse, reverse_lazy
@@ -68,10 +70,17 @@ class GroupedOrderDetailView(generic.DetailView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
+ # Get remaining quantities
qty_dict = {}
for item in self.get_object().item_set.all():
qty_dict[item.id] = item.get_remaining_nb()
context["remaining_qty"] = qty_dict
+
+ # Get a dict with prices for the js display of total price of an order
+ prices_dict = {}
+ for item in self.get_object().item_set.all():
+ prices_dict[item.id] = item.price
+ context["prices_dict"] = json.dumps(prices_dict, cls=DjangoJSONEncoder)
return context