diff --git a/la_chariotte/order/forms.py b/la_chariotte/order/forms.py index 8e28d5a..334339c 100644 --- a/la_chariotte/order/forms.py +++ b/la_chariotte/order/forms.py @@ -4,6 +4,7 @@ from django import forms from django.contrib.auth import get_user_model from django.forms.utils import to_current_timezone from django.utils import timezone +from pygments.lexer import default from la_chariotte.order.models import GroupedOrder, Item @@ -18,6 +19,10 @@ class GroupedOrderForm(forms.ModelForm): widget=forms.TimeInput(attrs={"type": "time"}), initial=datetime.time(hour=23, minute=59, second=59), ) + phone_mandatory = forms.BooleanField( + label="Numéro de téléphone obligatoire pour les participants", + required=False, + ) class Meta: model = GroupedOrder @@ -29,6 +34,7 @@ class GroupedOrderForm(forms.ModelForm): "delivery_slot", "place", "description", + "phone_mandatory" ] widgets = { "name": forms.TextInput( diff --git a/la_chariotte/order/migrations/0027_groupedorder_phone_mandatory.py b/la_chariotte/order/migrations/0027_groupedorder_phone_mandatory.py new file mode 100644 index 0000000..273749b --- /dev/null +++ b/la_chariotte/order/migrations/0027_groupedorder_phone_mandatory.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.11 on 2024-04-14 08:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("order", "0026_groupedorder_delivery_slot"), + ] + + operations = [ + migrations.AddField( + model_name="groupedorder", + name="phone_mandatory", + field=models.BooleanField( + default=False, verbose_name="Numéro de téléphone obligatoire" + ), + ), + ] diff --git a/la_chariotte/order/models.py b/la_chariotte/order/models.py index 55dd867..84d601f 100644 --- a/la_chariotte/order/models.py +++ b/la_chariotte/order/models.py @@ -27,6 +27,7 @@ class GroupedOrder(models.Model): description = models.TextField("Description", null=True, blank=True) total_price = models.DecimalField(max_digits=10, decimal_places=2, default=0) code = models.CharField(auto_created=True) + phone_mandatory = models.BooleanField(default=False, verbose_name="Numéro de téléphone obligatoire") def create_code_from_pk(self): """When a grouped order is created, a unique code is generated, to be used to diff --git a/la_chariotte/order/templates/order/grouped_order_create.html b/la_chariotte/order/templates/order/grouped_order_create.html index 3accfb1..01c8858 100644 --- a/la_chariotte/order/templates/order/grouped_order_create.html +++ b/la_chariotte/order/templates/order/grouped_order_create.html @@ -1,5 +1,7 @@ {% extends 'base.html' %} +{% load crispy_forms_tags %} + {% block title %}Nouvelle commande groupée{% endblock %} {% block content %} @@ -10,8 +12,9 @@
Nouvelle commande groupée