diff --git a/la_chariotte/order/templates/order/grouped_order_detail.html b/la_chariotte/order/templates/order/grouped_order_detail.html index fa9e947..81f3974 100644 --- a/la_chariotte/order/templates/order/grouped_order_detail.html +++ b/la_chariotte/order/templates/order/grouped_order_detail.html @@ -58,7 +58,7 @@
- +
@@ -74,7 +74,7 @@ + {% if item.get_remaining_nb is not null %} + + {% if item.get_remaining_nb == 0 %}Produit épuisé + {% else %} + {{ item.get_remaining_nb }} {% if item.get_remaining_nb == 1 %}disponible{% else %}disponibles{% endif %} + {% endif %}{% endif %} diff --git a/la_chariotte/order/templates/order/grouped_order_overview.html b/la_chariotte/order/templates/order/grouped_order_overview.html index 824b368..4b362fe 100644 --- a/la_chariotte/order/templates/order/grouped_order_overview.html +++ b/la_chariotte/order/templates/order/grouped_order_overview.html @@ -102,7 +102,7 @@
Produit{{ item.price }} € {% if item.get_remaining_nb is not null %} - + {% if item.get_remaining_nb == 0 %}Produit épuisé {% else %} {{ item.get_remaining_nb }} {% if item.get_remaining_nb == 1 %}disponible{% else %}disponibles{% endif %} @@ -97,8 +97,13 @@

{{ item.price }} €

{% else %} -

Vous n'avez pas ajouté de produits à cette commande groupée. Ajoutez-en ici

+

Vous n'avez pas ajouté de produits à cette commande groupée. Ajoutez-en ici

{% endif %} diff --git a/la_chariotte/order/tests/test_views.py b/la_chariotte/order/tests/test_views.py index 4acd77e..2889d42 100644 --- a/la_chariotte/order/tests/test_views.py +++ b/la_chariotte/order/tests/test_views.py @@ -434,7 +434,7 @@ class TestGroupedOrderDetailView: response = client.post( order_url, { - f"quantity_{item.pk}": 2, + f"quantity_{item.pk}": [2, 0], "first_name": "Prénom", "last_name": "Nom", "phone": "0645632569", @@ -480,7 +480,7 @@ class TestGroupedOrderDetailView: response = client.post( order_url, { - f"quantity_{item.pk}": 1, + f"quantity_{item.pk}": [0, 1], "first_name": "Prénom", "last_name": "Nom", "phone": "0645632569", @@ -526,7 +526,7 @@ class TestGroupedOrderDetailView: response = client.post( order_url, { - f"quantity_{item.pk}": 2, + f"quantity_{item.pk}": [2, 0], "first_name": "Prénom", "last_name": "Nom", "phone": "0645632569", @@ -537,7 +537,7 @@ class TestGroupedOrderDetailView: response = client.post( order_url, { - f"quantity_{item.pk}": 1, + f"quantity_{item.pk}": [1, 0], "first_name": "Prénom", "last_name": "Nom", "phone": "0645632569", @@ -590,8 +590,8 @@ class TestGroupedOrderDetailView: response = client.post( order_url, { - f"quantity_{item.pk}": 4, - f"quantity_{item2.pk}": 0, + f"quantity_{item.pk}": [4, 0], + f"quantity_{item2.pk}": [0, 0], "first_name": "Prénom", "last_name": "Nom", "phone": "0645632569", diff --git a/la_chariotte/order/views.py b/la_chariotte/order/views.py index 603aad8..95fca89 100644 --- a/la_chariotte/order/views.py +++ b/la_chariotte/order/views.py @@ -255,7 +255,7 @@ def order(request, grouped_order_id): def validate_item_ordered_nb(item, ordered_nb): """Returns an error message if the ordered items are not available""" - if item.get_remaining_nb() and item.get_remaining_nb() - ordered_nb < 0: + if item.get_remaining_nb() is not None and item.get_remaining_nb() - ordered_nb < 0: return f"Trop de {item.name} commandés pour la quantité disponible" return None