from django.db import models

class Tisub(models.Model):
    class Type(models.TextChoices):
        SHORT_TEXT = "ST"
        LONG_TEXT = "LT"
        COLOR = "C"
        YEAR_MONTH = "YM"
        BOOLEAN = "B"

    name = models.CharField(max_length=50)
    descritpion = models.TextField()
    default = models.TextField()
    # everything is text. type is for UX (e.g. color picker)
    type = models.CharField(max_length=2, choices=Type, default=Type.SHORT_TEXT)

    def __str__(self):
        return self.name

    class Meta:
        verbose_name_plural = "tisubz"


class Tikategory(models.Model):
    name = models.CharField(max_length=50)
    landscape = models.BooleanField()
    subs = models.ManyToManyField(Tisub)
    # For now we'll hardcode the following:xi
    #  [designation, ingredients, description, color, AB, designation_fontsize]
    #protosubs = models.ManyToManyField(Tisub, related_name="protosubs")
    prototempalte = models.FileField()

    def __str__(self):
        return self.name

    class Meta:
        verbose_name_plural = "tikategoriez"


class Tikette(models.Model):
    class AbVisibility(models.TextChoices):
        VISIBLE = "inline"
        INVISIBLE = "none"

    title = models.CharField(max_length=100)
    category = models.ForeignKey(Tikategory, on_delete=models.CASCADE)

    designation = models.CharField(max_length=100)
    ingredients = models.TextField()
    description = models.TextField()
    color = models.CharField(max_length=6)
    ab = models.CharField(max_length=7, choices=AbVisibility)
    # designation_fontsize is hardcoded to 42.6667 in planche/generate.py

    def __str__(self):
        return self.title

    class Meta:
        verbose_name_plural = "tikettz"


class Tizer(models.Model):
    email = models.CharField()

    def __str__(self):
        return self.email

    class Meta:
        verbose_name_plural = "tizerz"
