fix: show product in replacement of sub products in homepage
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 5.0.2 on 2026-05-26 12:44
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('products', '0010_release_version_main_product'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='mainproduct',
|
||||
name='homepage_order',
|
||||
field=models.PositiveIntegerField(default=0, help_text='Order within the homepage Products section.'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='mainproduct',
|
||||
name='show_on_homepage',
|
||||
field=models.BooleanField(default=False, help_text='Display this product in the homepage Products section.'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,26 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def copy_subproduct_homepage_flags(apps, schema_editor):
|
||||
SubProduct = apps.get_model("products", "SubProduct")
|
||||
for sub in (
|
||||
SubProduct.objects.filter(show_on_homepage=True)
|
||||
.select_related("main_product")
|
||||
.order_by("homepage_order", "order")
|
||||
):
|
||||
main = sub.main_product
|
||||
if not main.show_on_homepage:
|
||||
main.show_on_homepage = True
|
||||
main.homepage_order = sub.homepage_order
|
||||
main.save(update_fields=["show_on_homepage", "homepage_order"])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("products", "0011_mainproduct_homepage_order_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(copy_subproduct_homepage_flags, migrations.RunPython.noop),
|
||||
]
|
||||
Reference in New Issue
Block a user