diff --git a/la_chariotte/order/forms.py b/la_chariotte/order/forms.py
index 17865e7..dc66c3f 100644
--- a/la_chariotte/order/forms.py
+++ b/la_chariotte/order/forms.py
@@ -40,7 +40,7 @@ class GroupedOrderForm(ModelForm):
class ItemCreateForm(ModelForm):
class Meta:
model = Item
- fields = ["name"]
+ fields = ["name", "price", "max_limit"]
def __init__(self, *args, **kwargs):
self.grouped_order = kwargs.pop("grouped_order") # type: GroupedOrder
diff --git a/la_chariotte/order/migrations/0014_item_max_limit_item_price.py b/la_chariotte/order/migrations/0014_item_max_limit_item_price.py
new file mode 100644
index 0000000..cfc9ef9
--- /dev/null
+++ b/la_chariotte/order/migrations/0014_item_max_limit_item_price.py
@@ -0,0 +1,23 @@
+# Generated by Django 4.2 on 2023-05-09 13:44
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("order", "0013_alter_groupedorder_unique_together"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="item",
+ name="max_limit",
+ field=models.PositiveSmallIntegerField(blank=True, null=True),
+ ),
+ migrations.AddField(
+ model_name="item",
+ name="price",
+ field=models.DecimalField(decimal_places=2, default=1, max_digits=10),
+ preserve_default=False,
+ ),
+ ]
diff --git a/la_chariotte/order/models.py b/la_chariotte/order/models.py
index 51cbe13..d8d44d4 100644
--- a/la_chariotte/order/models.py
+++ b/la_chariotte/order/models.py
@@ -67,13 +67,16 @@ class Item(models.Model):
grouped_order = models.ForeignKey(
GroupedOrder, on_delete=models.CASCADE
) # à transformer en manytomany quand il y aura un catalogue
+ price = models.DecimalField(max_digits=10, decimal_places=2)
+ max_limit = models.PositiveSmallIntegerField(null=True, blank=True)
+
ordered_nb = models.IntegerField(default=0)
def get_absolute_url(self):
return reverse("order:manage_items", kwargs={"pk": self.grouped_order.pk})
def __str__(self): # pragma: no cover
- return f"{self.name} dans la commande groupée {self.grouped_order.pk}"
+ return f"{self.name} ({self.price} €)"
class OrderedItem(models.Model):
diff --git a/la_chariotte/order/templates/order/grouped_order_add_items.html b/la_chariotte/order/templates/order/grouped_order_add_items.html
index 5d6434d..885d3e8 100644
--- a/la_chariotte/order/templates/order/grouped_order_add_items.html
+++ b/la_chariotte/order/templates/order/grouped_order_add_items.html
@@ -16,6 +16,8 @@
@@ -24,11 +26,15 @@
Nom
+ Prix unitaire
+ Quantité max (optionnel)
Action