# SPDX-FileCopyrightText: 2017-present Tobias Kunze
# SPDX-License-Identifier: AGPL-3.0-only WITH LicenseRef-Pretalx-AGPL-3.0-Terms

# Generated by Django 5.1.7 on 2025-05-15 08:54

import django.db.models.deletion
import rules.contrib.models
from django.conf import settings
from django.db import migrations, models

import pretalx.common.models.mixins
import pretalx.person.models.auth_token


class Migration(migrations.Migration):

    dependencies = [
        ("event", "0039_alter_teaminvite_token"),
        ("person", "0029_alter_user_avatar_thumbnail_and_more"),
    ]

    operations = [
        migrations.CreateModel(
            name="UserApiToken",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True, primary_key=True, serialize=False
                    ),
                ),
                ("created", models.DateTimeField(auto_now_add=True, null=True)),
                ("updated", models.DateTimeField(auto_now=True, null=True)),
                ("name", models.CharField(max_length=190)),
                (
                    "token",
                    models.CharField(
                        default=pretalx.person.models.auth_token.generate_api_token,
                        max_length=64,
                        unique=True,
                    ),
                ),
                ("expires", models.DateTimeField(blank=True, null=True)),
                ("endpoints", models.JSONField(default=dict)),
                ("version", models.CharField(max_length=12, null=True)),
                ("last_used", models.DateTimeField(blank=True, null=True)),
                ("events", models.ManyToManyField(related_name="+", to="event.event")),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="api_tokens",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
            bases=(
                pretalx.common.models.mixins.LogMixin,
                pretalx.common.models.mixins.FileCleanupMixin,
                rules.contrib.models.RulesModelMixin,
                models.Model,
            ),
        ),
    ]
