# Generated by Django 5.2.4 on 2025-09-04 02:28

import core.entity
import django.contrib.auth.models
import django.contrib.auth.validators
import django.core.validators
import django.db.models.deletion
import django.utils.timezone
import utils.revision
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("auth", "0001_initial"),
        ("contenttypes", "__first__"),
        ("nodes", "0001_initial"),
    ]

    operations = [
        migrations.CreateModel(
            name="Brand",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("name", models.CharField(max_length=100, unique=True)),
            ],
            options={
                "verbose_name": "EV Brand",
                "verbose_name_plural": "EV Brands",
            },
        ),
        migrations.CreateModel(
            name="Product",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("name", models.CharField(max_length=100)),
                ("description", models.TextField(blank=True)),
                (
                    "renewal_period",
                    models.PositiveIntegerField(help_text="Renewal period in days"),
                ),
                (
                    "odoo_product",
                    models.JSONField(
                        blank=True,
                        null=True,
                        help_text="Selected product from Odoo (id and name)",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="User",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("password", models.CharField(max_length=128, verbose_name="password")),
                (
                    "last_login",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="last login"
                    ),
                ),
                (
                    "is_superuser",
                    models.BooleanField(
                        default=False,
                        help_text="Designates that this user has all permissions without explicitly assigning them.",
                        verbose_name="superuser status",
                    ),
                ),
                (
                    "username",
                    models.CharField(
                        error_messages={
                            "unique": "A user with that username already exists."
                        },
                        help_text="Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.",
                        max_length=150,
                        unique=True,
                        validators=[
                            django.contrib.auth.validators.UnicodeUsernameValidator()
                        ],
                        verbose_name="username",
                    ),
                ),
                (
                    "first_name",
                    models.CharField(
                        blank=True, max_length=150, verbose_name="first name"
                    ),
                ),
                (
                    "last_name",
                    models.CharField(
                        blank=True, max_length=150, verbose_name="last name"
                    ),
                ),
                (
                    "email",
                    models.EmailField(
                        blank=True, max_length=254, verbose_name="email address"
                    ),
                ),
                (
                    "is_staff",
                    models.BooleanField(
                        default=False,
                        help_text="Designates whether the user can log into this admin site.",
                        verbose_name="staff status",
                    ),
                ),
                (
                    "is_active",
                    models.BooleanField(
                        default=True,
                        help_text="Designates whether this user should be treated as active. Unselect this instead of deleting energy accounts.",
                        verbose_name="active",
                    ),
                ),
                (
                    "date_joined",
                    models.DateTimeField(
                        default=django.utils.timezone.now, verbose_name="date joined"
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                (
                    "phone_number",
                    models.CharField(
                        blank=True,
                        help_text="Optional contact phone number",
                        max_length=20,
                    ),
                ),
                ("birthday", models.DateField(blank=True, null=True)),
                ("has_charger", models.BooleanField(default=False)),
                (
                    "groups",
                    models.ManyToManyField(
                        blank=True,
                        help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
                        related_name="user_set",
                        related_query_name="user",
                        to="auth.group",
                        verbose_name="groups",
                    ),
                ),
                (
                    "user_permissions",
                    models.ManyToManyField(
                        blank=True,
                        help_text="Specific permissions for this user.",
                        related_name="user_set",
                        related_query_name="user",
                        to="auth.permission",
                        verbose_name="user permissions",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
            managers=[
                ("objects", core.entity.EntityUserManager()),
                ("all_objects", django.contrib.auth.models.UserManager()),
            ],
        ),
        migrations.CreateModel(
            name="Reference",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                (
                    "content_type",
                    models.CharField(
                        choices=[("text", "Text"), ("image", "Image")],
                        default="text",
                        max_length=5,
                    ),
                ),
                (
                    "alt_text",
                    models.CharField(max_length=500, verbose_name="Title / Alt Text"),
                ),
                ("value", models.TextField(blank=True)),
                ("file", models.FileField(blank=True, upload_to="refs/")),
                ("image", models.ImageField(blank=True, upload_to="refs/qr/")),
                ("uses", models.PositiveIntegerField(default=0)),
                ("method", models.CharField(default="qr", max_length=50)),
                (
                    "include_in_footer",
                    models.BooleanField(
                        default=False, verbose_name="Include in Footer"
                    ),
                ),
                ("created", models.DateTimeField(auto_now_add=True)),
                (
                    "author",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="references",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="EnergyAccount",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("name", models.CharField(max_length=100, unique=True)),
                (
                    "service_account",
                    models.BooleanField(
                        default=False,
                        help_text="Allow transactions even when the balance is zero or negative",
                    ),
                ),
                (
                    "user",
                    models.OneToOneField(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="energy_account",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
                "db_table": "core_account",
                "verbose_name": "Energy Account",
                "verbose_name_plural": "Energy Accounts",
            },
        ),
        migrations.CreateModel(
            name="EnergyCredit",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                (
                    "amount_kw",
                    models.DecimalField(
                        decimal_places=2, max_digits=10, verbose_name="Energy (kW)"
                    ),
                ),
                ("created_on", models.DateTimeField(auto_now_add=True)),
                (
                    "account",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="credits",
                        to="core.energyaccount",
                    ),
                ),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="credit_entries",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
                "db_table": "core_credit",
                "verbose_name": "Energy Credit",
                "verbose_name_plural": "Energy Credits",
            },
        ),
        migrations.CreateModel(
            name="EVModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("name", models.CharField(max_length=100)),
                (
                    "brand",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="ev_models",
                        to="core.brand",
                    ),
                ),
            ],
            options={
                "verbose_name": "EV Model",
                "verbose_name_plural": "EV Models",
                "unique_together": {("brand", "name")},
            },
        ),
        migrations.CreateModel(
            name="RFID",
            fields=[
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                (
                    "label_id",
                    models.AutoField(
                        db_column="label_id", primary_key=True, serialize=False
                    ),
                ),
                (
                    "rfid",
                    models.CharField(
                        max_length=255,
                        unique=True,
                        validators=[
                            django.core.validators.RegexValidator(
                                "^[0-9A-Fa-f]+$",
                                message="RFID must be hexadecimal digits",
                            )
                        ],
                        verbose_name="RFID",
                    ),
                ),
                (
                    "key_a",
                    models.CharField(
                        default="FFFFFFFFFFFF",
                        max_length=12,
                        validators=[
                            django.core.validators.RegexValidator(
                                "^[0-9A-Fa-f]{12}$",
                                message="Key must be 12 hexadecimal digits",
                            )
                        ],
                        verbose_name="Key A",
                    ),
                ),
                (
                    "key_b",
                    models.CharField(
                        default="FFFFFFFFFFFF",
                        max_length=12,
                        validators=[
                            django.core.validators.RegexValidator(
                                "^[0-9A-Fa-f]{12}$",
                                message="Key must be 12 hexadecimal digits",
                            )
                        ],
                        verbose_name="Key B",
                    ),
                ),
                ("allowed", models.BooleanField(default=True)),
                (
                    "color",
                    models.CharField(
                        choices=[
                            ("B", "Black"),
                            ("W", "White"),
                            ("U", "Blue"),
                            ("R", "Red"),
                            ("G", "Green"),
                        ],
                        default="B",
                        max_length=1,
                    ),
                ),
                ("released", models.BooleanField(default=False)),
                ("added_on", models.DateTimeField(auto_now_add=True)),
                (
                    "reference",
                    models.ForeignKey(
                        blank=True,
                        help_text="Optional reference for this RFID.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="rfids",
                        to="core.reference",
                    ),
                ),
            ],
            options={
                "verbose_name": "RFID",
                "verbose_name_plural": "RFIDs",
                "db_table": "core_rfid",
            },
        ),
        migrations.AddField(
            model_name="energyaccount",
            name="rfids",
            field=models.ManyToManyField(
                blank=True,
                db_table="core_account_rfids",
                related_name="energy_accounts",
                to="core.rfid",
                verbose_name="RFIDs",
            ),
        ),
        migrations.CreateModel(
            name="LiveSubscription",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("start_date", models.DateField(auto_now_add=True)),
                ("next_renewal", models.DateField(blank=True)),
                (
                    "account",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="core.energyaccount",
                    ),
                ),
                (
                    "product",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="core.product"
                    ),
                ),
            ],
            options={
                "verbose_name": "Live Subscription",
                "verbose_name_plural": "Live Subscriptions",
            },
        ),
        migrations.CreateModel(
            name="Vehicle",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                (
                    "vin",
                    models.CharField(max_length=17, unique=True, verbose_name="VIN"),
                ),
                (
                    "license_plate",
                    models.CharField(
                        blank=True, max_length=20, verbose_name="License Plate"
                    ),
                ),
                (
                    "account",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="vehicles",
                        to="core.energyaccount",
                    ),
                ),
                (
                    "brand",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="vehicles",
                        to="core.brand",
                    ),
                ),
                (
                    "model",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="vehicles",
                        to="core.evmodel",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="WMICode",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("code", models.CharField(max_length=3, unique=True)),
                (
                    "brand",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="wmi_codes",
                        to="core.brand",
                    ),
                ),
            ],
            options={
                "verbose_name": "WMI Code",
                "verbose_name_plural": "WMI Codes",
            },
        ),
        migrations.CreateModel(
            name="AdminHistory",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("url", models.TextField()),
                ("visited_at", models.DateTimeField(auto_now=True)),
                (
                    "content_type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="contenttypes.contenttype",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="admin_history",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-visited_at"],
                "unique_together": {("user", "url")},
                "verbose_name": "Admin History",
                "verbose_name_plural": "Admin Histories",
            },
        ),
        migrations.CreateModel(
            name="ReleaseManager",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                (
                    "pypi_username",
                    models.CharField(
                        blank=True, max_length=100, verbose_name="PyPI username"
                    ),
                ),
                (
                    "pypi_token",
                    models.CharField(
                        blank=True, max_length=200, verbose_name="PyPI token"
                    ),
                ),
                (
                    "github_token",
                    models.CharField(
                        blank=True,
                        help_text="Personal access token for GitHub operations. Used before the GITHUB_TOKEN environment variable.",
                        max_length=200,
                    ),
                ),
                (
                    "pypi_password",
                    models.CharField(
                        blank=True, max_length=200, verbose_name="PyPI password"
                    ),
                ),
                ("pypi_url", models.URLField(blank=True, verbose_name="PyPI URL")),
                (
                    "user",
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="release_manager",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Release Manager",
                "verbose_name_plural": "Release Managers",
            },
        ),
        migrations.CreateModel(
            name="Package",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                (
                    "name",
                    models.CharField(default="arthexis", max_length=100, unique=True),
                ),
                (
                    "description",
                    models.CharField(
                        default="Django-based MESH system", max_length=255
                    ),
                ),
                (
                    "author",
                    models.CharField(
                        default="Rafael J. Guillén-Osorio", max_length=100
                    ),
                ),
                (
                    "email",
                    models.EmailField(
                        default="tecnologia@gelectriic.com", max_length=254
                    ),
                ),
                ("python_requires", models.CharField(default=">=3.10", max_length=20)),
                ("license", models.CharField(default="MIT", max_length=100)),
                (
                    "repository_url",
                    models.URLField(default="https://github.com/arthexis/arthexis"),
                ),
                ("homepage_url", models.URLField(default="https://arthexis.com")),
                (
                    "release_manager",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="core.releasemanager",
                    ),
                ),
            ],
            options={
                "verbose_name": "Package",
                "verbose_name_plural": "Packages",
            },
        ),
        migrations.CreateModel(
            name="PackageRelease",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("version", models.CharField(default="0.0.0", max_length=20)),
                (
                    "revision",
                    models.CharField(
                        blank=True,
                        default=utils.revision.get_revision,
                        editable=False,
                        max_length=40,
                    ),
                ),
                (
                    "pypi_url",
                    models.URLField(
                        blank=True, editable=False, verbose_name="PyPI URL"
                    ),
                ),
                (
                    "package",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="releases",
                        to="core.package",
                    ),
                ),
                (
                    "release_manager",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="core.releasemanager",
                    ),
                ),
            ],
            options={
                "verbose_name": "Package Release",
                "verbose_name_plural": "Package Releases",
                "get_latest_by": "version",
                "constraints": [
                    models.UniqueConstraint(
                        fields=("package", "version"), name="unique_package_version"
                    )
                ],
            },
        ),
        migrations.CreateModel(
            name="OdooProfile",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("host", models.CharField(max_length=255)),
                ("database", models.CharField(max_length=255)),
                ("username", models.CharField(max_length=255)),
                ("password", models.CharField(max_length=255)),
                ("verified_on", models.DateTimeField(blank=True, null=True)),
                (
                    "odoo_uid",
                    models.PositiveIntegerField(blank=True, editable=False, null=True),
                ),
                ("name", models.CharField(blank=True, editable=False, max_length=255)),
                (
                    "email",
                    models.EmailField(blank=True, editable=False, max_length=254),
                ),
                (
                    "user",
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="odoo_profile",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Odoo Profile",
                "verbose_name_plural": "Odoo Profiles",
            },
        ),
    ]
