from django.db import models

class Applet(models.Model):
    DASHBOARD = "dashboard"
    GAMEBOARD = "gameboard"
    WALLET = "wallet"
    BILLBOARD = "billboard"
    CONTEXT_CHOICES = [
        (DASHBOARD, "Dashboard"),
        (GAMEBOARD, "Gameboard"),
        (WALLET, "Wallet"),
        (BILLBOARD, "Billboard"),
    ]

    slug = models.SlugField(unique=True)
    name = models.CharField(max_length=100)
    context = models.CharField(max_length=20, choices=CONTEXT_CHOICES, default=DASHBOARD)
    default_visible = models.BooleanField(default=True)
    grid_cols = models.PositiveSmallIntegerField(default=12)
    grid_rows = models.PositiveSmallIntegerField(default=3)

    def __str__(self):
        return self.name
    
class UserApplet(models.Model):
    user = models.ForeignKey(
        "lyric.User",
        related_name="user_applets",
        on_delete=models.CASCADE,
    )
    applet = models.ForeignKey(
        Applet,
        on_delete=models.CASCADE,
    )
    visible = models.BooleanField(default=True)

    class Meta:
        unique_together = ("user", "applet")
