feat: Force phone mandatory for already existing orders

This commit is contained in:
xmeunier 2024-12-08 17:04:35 +01:00 committed by Laetitia Getti
parent 6e4cb1c7d4
commit 523e26baaa
3 changed files with 22 additions and 21 deletions

View file

@ -1,19 +0,0 @@
# Generated by Django 4.2 on 2024-10-20 13:02
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("order", "0027_groupedorder_phone_mandatory"),
]
operations = [
migrations.AlterField(
model_name="order",
name="created_date",
field=models.DateTimeField(
auto_now_add=True, verbose_name="Date et heure de commande"
),
),
]

View file

@ -1,4 +1,4 @@
# Generated by Django 4.2.11 on 2024-04-14 08:58 # Generated by Django 4.2.16 on 2024-12-08 15:15
from django.db import migrations, models from django.db import migrations, models
@ -6,7 +6,7 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("order", "0026_groupedorder_delivery_slot"), ("order", "0027_remove_groupedorder_total_price_and_more"),
] ]
operations = [ operations = [

View file

@ -0,0 +1,20 @@
# Generated by Django 4.2.16 on 2024-12-08 15:41
from django.db import migrations
def set_phone_mandatory(apps, schema_editor):
"""For continuity, force mandatory phone for the orders that were created so far."""
GroupedOrder = apps.get_model("order", "GroupedOrder")
for grouped_order in GroupedOrder.objects.all():
grouped_order.is_phone_mandatory = True
grouped_order.save()
class Migration(migrations.Migration):
dependencies = [
("order", "0028_groupedorder_is_phone_mandatory"),
]
operations = [
migrations.RunPython(set_phone_mandatory),
]