# Generated by Django 4.1.8 on 2023-04-20 13:09

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


class Migration(migrations.Migration):
    dependencies = [
        ("authentication", "0003_alter_user_profile"),
    ]

    operations = [
        migrations.CreateModel(
            name="Token",
            fields=[
                ("key", models.CharField(max_length=40, primary_key=True, serialize=False, verbose_name="Key")),
                ("created", models.DateTimeField(auto_now_add=True, verbose_name="Created")),
                ("valid_until", models.DateTimeField(blank=True, null=True, verbose_name="Valid Until")),
                (
                    "protected_view_name",
                    models.CharField(
                        blank=True,
                        help_text="If specified, only view that revert to this viewname will accept this token",
                        max_length=256,
                        null=True,
                        verbose_name="Protected View-Name",
                    ),
                ),
                (
                    "number_usage_left",
                    models.PositiveIntegerField(blank=True, null=True, verbose_name="Number of allowed usage"),
                ),
                ("is_valid", models.BooleanField(default=True, verbose_name="Is Valid")),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="auth_tokens",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="User",
                    ),
                ),
            ],
            options={
                "verbose_name": "Token",
                "verbose_name_plural": "Tokens",
                "unique_together": {("user", "protected_view_name")},
            },
        ),
    ]
