# Generated by Django 4.2.16 on 2026-10-28 17:05

import apps.store.models
import django.core.validators
from django.db import migrations, models


def copy_old_settings(apps, schema_editor):
    Product = apps.get_model('store', 'Product')
    for p in Product.objects.all():
        p.digital_mode = 'paid' if p.digital_available else 'none'
        p.preview_pages = f'1-{p.free_pages}' if p.free_pages else ''
        p.save(update_fields=['digital_mode', 'preview_pages'])
import pathlib


class Migration(migrations.Migration):

    dependencies = [
        ('store', '0006_digitalaccess_user_order_user'),
    ]

    operations = [
        migrations.CreateModel(
            name='MagazineIssue',
            fields=[
            ],
            options={
                'verbose_name': 'Magazine issue',
                'verbose_name_plural': 'Magazine issues',
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('store.product',),
        ),
        migrations.CreateModel(
            name='NostalgicItem',
            fields=[
            ],
            options={
                'verbose_name': 'Nostalgic item',
                'verbose_name_plural': 'Nostalgic items',
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('store.product',),
        ),
        migrations.CreateModel(
            name='WearableHistoryProduct',
            fields=[
            ],
            options={
                'verbose_name': 'Wearable History product',
                'verbose_name_plural': 'Wearable History (merchandise)',
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('store.product',),
        ),
        migrations.AddField(
            model_name='product',
            name='contents',
            field=models.TextField(blank=True, help_text="What's inside — one item per line, e.g. '০০১ ভিস্তিওয়ালা — মশকে ভরা শহরের তৃষ্ণা'."),
        ),
        migrations.AddField(
            model_name='product',
            name='digital_mode',
            field=models.CharField(choices=[('none', 'No digital version (print only)'), ('free', 'Free — anyone can read the whole issue online'), ('paid', 'Paid — selected pages free, rest unlocked after payment')], default='paid', help_text='How the digital (online) edition works.', max_length=5),
        ),
        migrations.AddField(
            model_name='product',
            name='is_featured',
            field=models.BooleanField(default=False, help_text='Show first on the homepage and at the top of its shop/magazine page.'),
        ),
        migrations.AddField(
            model_name='product',
            name='preview_page_list',
            field=models.JSONField(blank=True, default=list, editable=False),
        ),
        migrations.AddField(
            model_name='product',
            name='preview_pages',
            field=models.CharField(blank=True, default='1-3', help_text="Paid issues: pages anyone can read free, e.g. '1-3, 7, 10-11'.", max_length=200),
        ),
        migrations.AddField(
            model_name='product',
            name='subtitle',
            field=models.CharField(blank=True, help_text='One-line hook shown under the title.', max_length=200),
        ),
        migrations.AlterField(
            model_name='product',
            name='digital_price',
            field=models.DecimalField(blank=True, decimal_places=2, help_text='Price to unlock the full digital issue (Paid only).', max_digits=8, null=True),
        ),
        migrations.AlterField(
            model_name='product',
            name='image',
            field=models.ImageField(help_text='Main photo. For a magazine: the cover (portrait, ideally 1200×1700).', upload_to='store/products/'),
        ),
        migrations.AlterField(
            model_name='product',
            name='is_active',
            field=models.BooleanField(default=True, help_text='Untick to hide from the website.'),
        ),
        migrations.AlterField(
            model_name='product',
            name='issue_label',
            field=models.CharField(blank=True, help_text='e.g. সংখ্যা ০১ · কার্তিক ১৪৩৩', max_length=60),
        ),
        migrations.AlterField(
            model_name='product',
            name='pdf_file',
            field=models.FileField(blank=True, help_text='Full magazine PDF (max 120 MB). Stored privately.', storage=apps.store.models.PrivateStorage(), upload_to='magazines/', validators=[django.core.validators.FileExtensionValidator(['pdf']), apps.store.models.validate_pdf]),
        ),
        migrations.AlterField(
            model_name='product',
            name='price',
            field=models.DecimalField(decimal_places=2, default=0, help_text='Selling price. For a magazine this is the PRINTED copy price.', max_digits=10),
        ),
        migrations.AlterField(
            model_name='product',
            name='product_type',
            field=models.CharField(choices=[('magazine', 'Magazine issue'), ('merch', 'Wearable History (T-shirts & merchandise)'), ('nostalgic', 'Nostalgic item')], db_index=True, default='merch', max_length=10),
        ),
        migrations.RunPython(copy_old_settings, migrations.RunPython.noop),
        migrations.RemoveField(
            model_name='product',
            name='digital_available',
        ),
        migrations.RemoveField(
            model_name='product',
            name='free_pages',
        ),
    ]
