# Generated by Django 5.1.7 on 2025-04-02 08:07

import card.storage
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("card", "0002_initial"),
    ]

    operations = [
        migrations.RemoveField(
            model_name="card",
            name="quantity",
        ),
        migrations.AddField(
            model_name="card",
            name="batch",
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="cards",
                to="card.cardbatch",
                verbose_name="批次",
            ),
        ),
        migrations.AddField(
            model_name="cardbatch",
            name="published",
            field=models.BooleanField(default=False, verbose_name="已发布"),
        ),
        migrations.AddField(
            model_name="cardbatch",
            name="published_at",
            field=models.DateTimeField(blank=True, null=True, verbose_name="发布时间"),
        ),
        migrations.AddField(
            model_name="cardbatch",
            name="status",
            field=models.CharField(
                choices=[
                    ("draft", "草稿"),
                    ("exported", "已导出"),
                    ("in_production", "生产中"),
                    ("produced", "已生产"),
                    ("published", "已发布"),
                ],
                default="draft",
                max_length=20,
                verbose_name="状态",
            ),
        ),
        migrations.AlterField(
            model_name="cardusagelog",
            name="action",
            field=models.CharField(
                choices=[
                    ("scan", "扫描"),
                    ("use", "使用"),
                    ("void", "作废"),
                    ("publish", "发布"),
                    ("manufacture", "生产"),
                ],
                max_length=20,
                verbose_name="操作",
            ),
        ),
        migrations.AlterField(
            model_name="cardusagelog",
            name="card",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="usage_logs",
                to="card.card",
                verbose_name="卡片",
            ),
        ),
        migrations.CreateModel(
            name="CardTemplate",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=100, verbose_name="名称")),
                ("description", models.TextField(blank=True, verbose_name="描述")),
                (
                    "card_type",
                    models.CharField(
                        choices=[
                            ("regular", "常规"),
                            ("seasonal", "季节限定"),
                            ("event", "活动限定"),
                        ],
                        default="regular",
                        max_length=20,
                        verbose_name="类型",
                    ),
                ),
                (
                    "rarity",
                    models.CharField(
                        choices=[
                            ("common", "普通"),
                            ("uncommon", "不常见"),
                            ("rare", "稀有"),
                            ("epic", "史诗"),
                            ("legendary", "传说"),
                            ("limited", "限定"),
                        ],
                        default="common",
                        max_length=20,
                        verbose_name="稀有度",
                    ),
                ),
                (
                    "image",
                    models.ImageField(
                        blank=True,
                        null=True,
                        storage=card.storage.OSSStorage(base_dir="cards"),
                        upload_to="templates/images/",
                        verbose_name="展示图片",
                    ),
                ),
                (
                    "model_url",
                    models.URLField(
                        blank=True, max_length=255, null=True, verbose_name="模型包链接"
                    ),
                ),
                (
                    "model_version",
                    models.CharField(
                        blank=True, max_length=20, null=True, verbose_name="模型版本"
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("draft", "草稿"),
                            ("published", "已发布"),
                            ("archived", "已归档"),
                        ],
                        default="draft",
                        max_length=20,
                        verbose_name="状态",
                    ),
                ),
                (
                    "published_at",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="发布时间"
                    ),
                ),
                (
                    "price",
                    models.DecimalField(
                        decimal_places=2, default=0, max_digits=10, verbose_name="价格"
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(auto_now_add=True, verbose_name="创建时间"),
                ),
                (
                    "updated_at",
                    models.DateTimeField(auto_now=True, verbose_name="更新时间"),
                ),
                (
                    "category",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="card.cardcategory",
                        verbose_name="类别",
                    ),
                ),
            ],
            options={
                "verbose_name": "卡片模板",
                "verbose_name_plural": "卡片模板",
                "ordering": ["-created_at"],
            },
        ),
        migrations.AddField(
            model_name="card",
            name="template",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="cards",
                to="card.cardtemplate",
                verbose_name="卡片模板",
            ),
        ),
        migrations.AddField(
            model_name="cardbatch",
            name="template",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="batches",
                to="card.cardtemplate",
                verbose_name="卡片模板",
            ),
        ),
    ]
