diff --git a/la_chariotte/order/templates/order/grouped_order_detail.html b/la_chariotte/order/templates/order/grouped_order_detail.html
index ff1c7d8..4565b50 100644
--- a/la_chariotte/order/templates/order/grouped_order_detail.html
+++ b/la_chariotte/order/templates/order/grouped_order_detail.html
@@ -79,7 +79,7 @@
{% csrf_token %}
{{ item.name }}
{{ item.price }} €
-
+
{% if item.get_remaining_nb is not null %}
{% if item.get_remaining_nb == 0 %}Produit épuisé
@@ -104,7 +104,7 @@
{{ item.price }} €
{% if error_message %}{{ error_message }}
{% endif %}
+ {% comment %} The value attribute is used when the form is redered with error messages,
+ in order not to loose entered values {% endcomment %}
Vos informations
- Note à l'organisateur·ice
-
+ Note à l'organisateur·ice
+
diff --git a/la_chariotte/order/tests/test_views.py b/la_chariotte/order/tests/test_views.py
index 44b9fe2..62bab6d 100644
--- a/la_chariotte/order/tests/test_views.py
+++ b/la_chariotte/order/tests/test_views.py
@@ -319,7 +319,7 @@ class TestGroupedOrderDetailView:
"""
From the OrderDetailView, we order without having changed any item quantity.
An error is raised.
- The order is deleted
+ The order is deleted, and the form is displayed without deleting entered values
"""
grouped_order = create_grouped_order(
days_before_delivery_date=5,
@@ -351,11 +351,11 @@ class TestGroupedOrderDetailView:
order_url,
{
f"quantity_{item.pk}": [0, 0],
- "first_name": "Prénom",
- "last_name": "Nom",
+ "first_name": "Prénom test",
+ "last_name": "Nom test",
"phone": "0645632569",
"email": "test@mail.fr",
- "note": "",
+ "note": "test note",
},
)
assert response.status_code == 200
@@ -363,6 +363,12 @@ class TestGroupedOrderDetailView:
response.context["error_message"]
== "Veuillez commander au moins un produit"
)
+ assert response.context["first_name"] == "Prénom test"
+ assert "Prénom test" in response.content.decode()
+ assert "Nom test" in response.content.decode()
+ assert "0645632569" in response.content.decode()
+ assert "test@mail.fr" in response.content.decode()
+ assert "test note" in response.content.decode()
assert not models.Order.objects.first()
assert not models.OrderAuthor.objects.first()
diff --git a/la_chariotte/order/views/order.py b/la_chariotte/order/views/order.py
index d8809d2..79c4c31 100644
--- a/la_chariotte/order/views/order.py
+++ b/la_chariotte/order/views/order.py
@@ -64,6 +64,11 @@ def order(request, grouped_order_id):
{
"grouped_order": grouped_order,
"error_message": error_message,
+ "first_name": author.first_name,
+ "last_name": author.last_name,
+ "phone": author.phone,
+ "email": author.email,
+ "note": order.note,
},
)
@@ -80,6 +85,11 @@ def order(request, grouped_order_id):
{
"grouped_order": grouped_order,
"error_message": error_message,
+ "first_name": author.first_name,
+ "last_name": author.last_name,
+ "phone": author.phone,
+ "email": author.email,
+ "note": order.note,
},
)