import uuid

from django.conf import settings
from django.db import models
from model_utils.models import TimeStampedModel


class SimpleList(TimeStampedModel):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    title = models.CharField(max_length=255)
    user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)

    def __str__(self):
        return f"{self.title} ({self.user})"


class SimpleTask(TimeStampedModel):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    title = models.CharField(max_length=255)
    text = models.TextField(blank=True, default="")
    done = models.BooleanField(default=False)
    deadline = models.DateTimeField(blank=True, null=True)

    list = models.ForeignKey(SimpleList, on_delete=models.CASCADE)
