fixes on add item form and displayed quantities

closes #81
This commit is contained in:
Laetitia Getti 2023-06-20 11:29:02 +02:00
parent 287db27ac3
commit 725ad6ddbe
2 changed files with 11 additions and 6 deletions

View file

@ -22,7 +22,7 @@
<tr>
<th>Nom</th>
<th>Prix unitaire</th>
<th>Quantité max (optionnel)</th>
<th>Quantité disponible (optionnel)</th>
<th>Action</th>
</tr>
</thead>
@ -31,8 +31,8 @@
<form method="post" action="{{ create_item_url }}">
{% csrf_token %}
<td><input name="name" maxlength="100" placeholder="Nom du produit" autofocus required></input></td>
<td><input name="price" size="2" placeholder="5,40" required></input></td>
<td><input name="max_limit" size="2" placeholder="42"></input></td>
<td><input type="number" min="0" step="0.01" name="price" size="2" placeholder="5,40" required></input></td>
<td><input type="number" min="0" name="max_limit" size="2" placeholder="42"></input></td>
<td><button type="submit" class="button is-primary">Ajouter</button></td>
</form>
</tr>
@ -40,7 +40,7 @@
<tr>
<td>{{ item.name }}</td>
<td>{{ item.price }}</td>
<td>{% if item.max_limit %}{{ item.max_limit }}{% else %}---{% endif %}</td>
<td>{% if item.max_limit is not null %}{{ item.max_limit }}{% else %}---{% endif %}</td>
<td>
{% if item.ordered_nb == 0 %}
<button class="button is-light is-small js-modal-trigger" data-target="confirm-delete-{{ item.id }}">

View file

@ -64,8 +64,13 @@
{% csrf_token %}
<td>{{ item.name }}</td>
<td>{{ item.price }} €</td>
<td><input name="quantity_{{ item.id }}" size="2" type="number" value="0" min="0"></input>
{% if item.get_remaining_nb is not null %}<span class="is-italic"> {{ item.get_remaining_nb }} {% if item.get_remaining_nb <= 1 %}disponible{% else %}disponibles{% endif %}</span>{% endif %}</td>
<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 %}
<span class="is-italic">
{% 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 %}</td>
</tr>
{% endfor %}
</tbody>