fixes after rebase

This commit is contained in:
Laetitia Getti 2023-06-21 14:59:37 +02:00
parent ef00d0b367
commit bc83967330
4 changed files with 17 additions and 12 deletions

View file

@ -58,7 +58,7 @@
<form method="post" action="{% url 'order:order' grouped_order.id %}"> <form method="post" action="{% url 'order:order' grouped_order.id %}">
<!-- Tableau de commandes - sur ordi --> <!-- Tableau de commandes - sur ordi -->
<table class="table is-hidden-mobile"> <table class="table is-hidden-touch">
<thead> <thead>
<tr> <tr>
<th>Produit</th> <th>Produit</th>
@ -74,7 +74,7 @@
<td>{{ item.price }} €</td> <td>{{ item.price }} €</td>
<td><input name="quantity_{{ item.id }}" size="2" type="number" value="0" min="0" {% if item.get_remaining_nb == 0 %}disabled{% endif %}></input> <td><input name="quantity_{{ item.id }}" size="2" type="number" value="0" min="0" {% if item.get_remaining_nb == 0 %}disabled{% endif %}></input>
{% if item.get_remaining_nb is not null %} {% if item.get_remaining_nb is not null %}
<span class="is-italic"> <span class="is-italic mini-title">
{% if item.get_remaining_nb == 0 %}Produit épuisé {% if item.get_remaining_nb == 0 %}Produit épuisé
{% else %} {% else %}
{{ item.get_remaining_nb }} {% if item.get_remaining_nb == 1 %}disponible{% else %}disponibles{% endif %}</span> {{ item.get_remaining_nb }} {% if item.get_remaining_nb == 1 %}disponible{% else %}disponibles{% endif %}</span>
@ -97,8 +97,13 @@
<p>{{ item.price }} €</p> <p>{{ item.price }} €</p>
</div> </div>
<div class="card-footer-item"> <div class="card-footer-item">
<input name="quantity_{{ item.id }}" size="2" type="number" value="0" min="0"></input> <td><input name="quantity_{{ item.id }}" size="2" type="number" value="0" min="0" {% if item.get_remaining_nb == 0 %}disabled{% endif %}></input></td>
{% if item.get_remaining_nb %}<span class="is-italic mini-title"> {{ item.get_remaining_nb }} {% if item.get_remaining_nb == 1 %}disponible{% else %}disponibles{% endif %}</span>{% endif %} {% if item.get_remaining_nb is not null %}
<span class="is-italic mini-title">
{% if item.get_remaining_nb == 0 %}Produit épuisé
{% else %}
{{ item.get_remaining_nb }} {% if item.get_remaining_nb == 1 %}disponible{% else %}disponibles{% endif %}</span>
{% endif %}{% endif %}
</div> </div>
</div> </div>
</div> </div>

View file

@ -102,7 +102,7 @@
</tfoot> </tfoot>
</table> </table>
{% else %} {% else %}
<p>Vous n'avez pas ajouté de produits à cette commande groupée. Ajoutez-en <a href="{% url 'order:manage_items' %}">ici</a></p> <p>Vous n'avez pas ajouté de produits à cette commande groupée. Ajoutez-en <a href="{% url 'order:manage_items' grouped_order.pk %}">ici</a></p>
{% endif %} {% endif %}
</div> </div>

View file

@ -434,7 +434,7 @@ class TestGroupedOrderDetailView:
response = client.post( response = client.post(
order_url, order_url,
{ {
f"quantity_{item.pk}": 2, f"quantity_{item.pk}": [2, 0],
"first_name": "Prénom", "first_name": "Prénom",
"last_name": "Nom", "last_name": "Nom",
"phone": "0645632569", "phone": "0645632569",
@ -480,7 +480,7 @@ class TestGroupedOrderDetailView:
response = client.post( response = client.post(
order_url, order_url,
{ {
f"quantity_{item.pk}": 1, f"quantity_{item.pk}": [0, 1],
"first_name": "Prénom", "first_name": "Prénom",
"last_name": "Nom", "last_name": "Nom",
"phone": "0645632569", "phone": "0645632569",
@ -526,7 +526,7 @@ class TestGroupedOrderDetailView:
response = client.post( response = client.post(
order_url, order_url,
{ {
f"quantity_{item.pk}": 2, f"quantity_{item.pk}": [2, 0],
"first_name": "Prénom", "first_name": "Prénom",
"last_name": "Nom", "last_name": "Nom",
"phone": "0645632569", "phone": "0645632569",
@ -537,7 +537,7 @@ class TestGroupedOrderDetailView:
response = client.post( response = client.post(
order_url, order_url,
{ {
f"quantity_{item.pk}": 1, f"quantity_{item.pk}": [1, 0],
"first_name": "Prénom", "first_name": "Prénom",
"last_name": "Nom", "last_name": "Nom",
"phone": "0645632569", "phone": "0645632569",
@ -590,8 +590,8 @@ class TestGroupedOrderDetailView:
response = client.post( response = client.post(
order_url, order_url,
{ {
f"quantity_{item.pk}": 4, f"quantity_{item.pk}": [4, 0],
f"quantity_{item2.pk}": 0, f"quantity_{item2.pk}": [0, 0],
"first_name": "Prénom", "first_name": "Prénom",
"last_name": "Nom", "last_name": "Nom",
"phone": "0645632569", "phone": "0645632569",

View file

@ -255,7 +255,7 @@ def order(request, grouped_order_id):
def validate_item_ordered_nb(item, ordered_nb): def validate_item_ordered_nb(item, ordered_nb):
"""Returns an error message if the ordered items are not available""" """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 f"Trop de {item.name} commandés pour la quantité disponible"
return None return None