# Generated by Django 5.2.9 on 2026-01-03 11:47

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("policy", "0004_hedgepositionmodel"),
    ]

    operations = [
        migrations.CreateModel(
            name="RSSHubGlobalConfig",
            fields=[
                (
                    "singleton_id",
                    models.AutoField(primary_key=True, serialize=False, verbose_name="单例ID"),
                ),
                (
                    "base_url",
                    models.URLField(
                        default="http://127.0.0.1:1200",
                        help_text="本地 RSSHub 服务的基址，如 http://127.0.0.1:1200",
                        max_length=500,
                        verbose_name="RSSHub 基址",
                    ),
                ),
                (
                    "access_key",
                    models.CharField(
                        blank=True,
                        help_text="RSSHub 的 ACCESS_KEY，留空表示不使用鉴权",
                        max_length=200,
                        verbose_name="访问密钥",
                    ),
                ),
                (
                    "enabled",
                    models.BooleanField(
                        default=False,
                        help_text="是否启用 RSSHub 全局配置",
                        verbose_name="启用 RSSHub",
                    ),
                ),
                (
                    "default_format",
                    models.CharField(
                        choices=[("rss", "RSS 2.0"), ("atom", "Atom"), ("json", "JSON Feed")],
                        default="rss",
                        help_text="RSSHub 默认输出格式",
                        max_length=20,
                        verbose_name="默认输出格式",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True, verbose_name="创建时间")),
                ("updated_at", models.DateTimeField(auto_now=True, verbose_name="更新时间")),
            ],
            options={
                "verbose_name": "RSSHub 全局配置",
                "verbose_name_plural": "RSSHub 全局配置",
                "db_table": "rsshub_global_config",
            },
        ),
        migrations.AddField(
            model_name="rsssourceconfigmodel",
            name="rsshub_custom_access_key",
            field=models.CharField(
                blank=True,
                help_text="仅在「不使用全局配置」时生效",
                max_length=200,
                verbose_name="自定义访问密钥",
            ),
        ),
        migrations.AddField(
            model_name="rsssourceconfigmodel",
            name="rsshub_custom_base_url",
            field=models.URLField(
                blank=True,
                help_text="仅在「不使用全局配置」时生效",
                max_length=500,
                verbose_name="自定义 RSSHub 基址",
            ),
        ),
        migrations.AddField(
            model_name="rsssourceconfigmodel",
            name="rsshub_enabled",
            field=models.BooleanField(
                default=False,
                help_text="是否使用 RSSHub 模式（启用后将忽略 URL 字段，使用路由路径）",
                verbose_name="使用 RSSHub",
            ),
        ),
        migrations.AddField(
            model_name="rsssourceconfigmodel",
            name="rsshub_format",
            field=models.CharField(
                blank=True,
                choices=[("", "默认"), ("rss", "RSS 2.0"), ("atom", "Atom"), ("json", "JSON Feed")],
                default="",
                help_text="留空则使用全局配置的默认格式",
                max_length=20,
                verbose_name="输出格式",
            ),
        ),
        migrations.AddField(
            model_name="rsssourceconfigmodel",
            name="rsshub_route_path",
            field=models.CharField(
                blank=True,
                help_text="如 /csrc/news/bwj，完整 URL 将自动构建为: 基址 + 路由 + key",
                max_length=500,
                verbose_name="RSSHub 路由路径",
            ),
        ),
        migrations.AddField(
            model_name="rsssourceconfigmodel",
            name="rsshub_use_global_config",
            field=models.BooleanField(
                default=True,
                help_text="是否使用全局 RSSHub 配置（基址和密钥）。取消勾选后可自定义配置。",
                verbose_name="使用全局 RSSHub 配置",
            ),
        ),
    ]
