# Generated by Django 5.2.7 on 2025-11-01 23:00

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


class Migration(migrations.Migration):

    dependencies = [
        ("core", "0081_clientreport_language_clientreport_title_and_more"),
        ("ocpp", "0034_charger_network_fields"),
    ]

    operations = [
        migrations.CreateModel(
            name="CPReservation",
            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_user_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                (
                    "id_tag",
                    models.CharField(
                        blank=True,
                        default="",
                        help_text="Identifier sent to the EVCS when reserving the connector.",
                        max_length=255,
                        verbose_name="Id Tag",
                    ),
                ),
                ("start_time", models.DateTimeField(verbose_name="Start time")),
                (
                    "duration_minutes",
                    models.PositiveIntegerField(
                        default=120,
                        help_text="Reservation window length in minutes.",
                        verbose_name="Duration (minutes)",
                    ),
                ),
                (
                    "evcs_status",
                    models.CharField(
                        blank=True,
                        default="",
                        max_length=32,
                        verbose_name="EVCS status",
                    ),
                ),
                (
                    "evcs_error",
                    models.CharField(
                        blank=True,
                        default="",
                        max_length=255,
                        verbose_name="EVCS error",
                    ),
                ),
                (
                    "evcs_confirmed",
                    models.BooleanField(
                        default=False, verbose_name="Reservation confirmed"
                    ),
                ),
                (
                    "evcs_confirmed_at",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="Confirmed at"
                    ),
                ),
                (
                    "ocpp_message_id",
                    models.CharField(
                        blank=True,
                        default="",
                        editable=False,
                        max_length=36,
                        verbose_name="OCPP message id",
                    ),
                ),
                (
                    "created_on",
                    models.DateTimeField(auto_now_add=True, verbose_name="Created on"),
                ),
                (
                    "updated_on",
                    models.DateTimeField(auto_now=True, verbose_name="Updated on"),
                ),
                (
                    "account",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="cp_reservations",
                        to="core.energyaccount",
                        verbose_name="Energy account",
                    ),
                ),
                (
                    "connector",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="reservations",
                        to="ocpp.charger",
                        verbose_name="Connector",
                    ),
                ),
                (
                    "location",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="reservations",
                        to="ocpp.location",
                        verbose_name="Location",
                    ),
                ),
                (
                    "rfid",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="cp_reservations",
                        to="core.rfid",
                        verbose_name="RFID",
                    ),
                ),
            ],
            options={
                "verbose_name": "CP Reservation",
                "verbose_name_plural": "CP Reservations",
                "ordering": ["-start_time"],
            },
        ),
    ]
