# Generated by Django 5.1 on 2024-09-08 16:55

import uuid

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


class Migration(migrations.Migration):
    dependencies = [
        ("core", "0002_create_pg_trgm_extension"),
    ]

    operations = [
        migrations.AddField(
            model_name="document",
            name="link_reach",
            field=models.CharField(
                choices=[
                    ("restricted", "Restricted"),
                    ("authenticated", "Authenticated"),
                    ("public", "Public"),
                ],
                default="authenticated",
                max_length=20,
            ),
        ),
        migrations.AddField(
            model_name="document",
            name="link_role",
            field=models.CharField(
                choices=[("reader", "Reader"), ("editor", "Editor")],
                default="reader",
                max_length=20,
            ),
        ),
        migrations.AlterField(
            model_name="document",
            name="is_public",
            field=models.BooleanField(null=True),
        ),
        migrations.AlterField(
            model_name="user",
            name="language",
            field=models.CharField(
                choices="(('en-us', 'English'), ('fr-fr', 'French'))",
                default="en-us",
                help_text="The language in which the user wants to see the interface.",
                max_length=10,
                verbose_name="language",
            ),
        ),
        migrations.CreateModel(
            name="LinkTrace",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        help_text="primary key for the record as UUID",
                        primary_key=True,
                        serialize=False,
                        verbose_name="id",
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        auto_now_add=True,
                        help_text="date and time at which a record was created",
                        verbose_name="created on",
                    ),
                ),
                (
                    "updated_at",
                    models.DateTimeField(
                        auto_now=True,
                        help_text="date and time at which a record was last updated",
                        verbose_name="updated on",
                    ),
                ),
                (
                    "document",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="link_traces",
                        to="core.document",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="link_traces",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Document/user link trace",
                "verbose_name_plural": "Document/user link traces",
                "db_table": "impress_link_trace",
                "constraints": [
                    models.UniqueConstraint(
                        fields=("user", "document"),
                        name="unique_link_trace_document_user",
                        violation_error_message="A link trace already exists for this document/user.",
                    )
                ],
            },
        ),
    ]
