diff --git a/la_chariotte/order/forms.py b/la_chariotte/order/forms.py index 51c03cc..2cf2817 100644 --- a/la_chariotte/order/forms.py +++ b/la_chariotte/order/forms.py @@ -18,7 +18,7 @@ class GroupedOrderForm(forms.ModelForm): widget=forms.TimeInput(attrs={"type": "time"}), initial=datetime.time(hour=23, minute=59, second=59), ) - phone_mandatory = forms.BooleanField( + is_phone_mandatory = forms.BooleanField( label="Numéro de téléphone obligatoire pour les participants", required=False, ) @@ -33,7 +33,7 @@ class GroupedOrderForm(forms.ModelForm): "delivery_slot", "place", "description", - "phone_mandatory", + "is_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 index 273749b..b81e9d1 100644 --- a/la_chariotte/order/migrations/0027_groupedorder_phone_mandatory.py +++ b/la_chariotte/order/migrations/0027_groupedorder_phone_mandatory.py @@ -12,7 +12,7 @@ class Migration(migrations.Migration): operations = [ migrations.AddField( model_name="groupedorder", - name="phone_mandatory", + name="is_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 dc5257e..9b5aeca 100644 --- a/la_chariotte/order/models.py +++ b/la_chariotte/order/models.py @@ -27,7 +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( + is_phone_mandatory = models.BooleanField( default=False, verbose_name="Numéro de téléphone obligatoire" ) diff --git a/la_chariotte/order/templates/order/grouped_order_detail.html b/la_chariotte/order/templates/order/grouped_order_detail.html index ef6a892..b73d467 100644 --- a/la_chariotte/order/templates/order/grouped_order_detail.html +++ b/la_chariotte/order/templates/order/grouped_order_detail.html @@ -158,11 +158,11 @@ value="{{ order_author.last_name }}" required>
+
+ {% if is_phone_mandatory %}required{% endif %}>
diff --git a/la_chariotte/order/views/grouped_order.py b/la_chariotte/order/views/grouped_order.py index 1ec6e29..b24d8c1 100644 --- a/la_chariotte/order/views/grouped_order.py +++ b/la_chariotte/order/views/grouped_order.py @@ -136,7 +136,7 @@ class GroupedOrderDetailView(generic.DetailView): "remaining_qty": remaining_qty, "order_author": order_author, # Used to set if the phone is required in the form - "phone_required": grouped_order.phone_mandatory, + "is_phone_mandatory": grouped_order.is_phone_mandatory, } ) return context diff --git a/la_chariotte/tests/test_order_views_grouped_order.py b/la_chariotte/tests/test_order_views_grouped_order.py index 3d04f38..5aefcc4 100644 --- a/la_chariotte/tests/test_order_views_grouped_order.py +++ b/la_chariotte/tests/test_order_views_grouped_order.py @@ -670,7 +670,7 @@ class TestGroupedOrderDetailView: name="gr order test", orga_user=other_user, ) - assert grouped_order.phone_mandatory == True + assert grouped_order.is_phone_mandatory == True item = models.Item.objects.create( name="test item 1", grouped_order=grouped_order, price=1, max_limit=2 ) @@ -686,7 +686,7 @@ class TestGroupedOrderDetailView: assert ( "Numéro de téléphone (facultatif)" not in response.content.decode() ) - grouped_order.phone_mandatory = False + grouped_order.is_phone_mandatory = False grouped_order.save() response = client.get(detail_url) assert "gr order test" in response.content.decode() diff --git a/la_chariotte/tests/utils.py b/la_chariotte/tests/utils.py index 7308c0f..a404d5b 100644 --- a/la_chariotte/tests/utils.py +++ b/la_chariotte/tests/utils.py @@ -13,7 +13,7 @@ def create_grouped_order( days_before_deadline, name, orga_user, - phone_mandatory=True, + is_phone_mandatory=True, ): date = timezone.now().date() + datetime.timedelta(days=days_before_delivery_date) deadline = timezone.now() + datetime.timedelta(days=days_before_deadline) @@ -22,7 +22,7 @@ def create_grouped_order( orga=orga_user, delivery_date=date, deadline=deadline, - phone_mandatory=phone_mandatory, + is_phone_mandatory=is_phone_mandatory, ) grouped_order.create_code_from_pk() grouped_order.save()