from uuid import uuid4

from django.db import models
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from main.models import NummiModel


class Category(NummiModel):
    id = models.UUIDField(primary_key=True, default=uuid4, editable=False)
    name = models.CharField(
        max_length=64, default=_("Category"), verbose_name=_("Name")
    )
    icon = models.SlugField(
        max_length=24,
        default="folder",
        verbose_name=_("Icon"),
    )
    budget = models.BooleanField(default=True, verbose_name=_("Budget"))

    def __str__(self):
        return str(self.name)

    def get_absolute_url(self):
        return reverse("category", args=(self.pk,))

    def get_delete_url(self):
        return reverse("del_category", args=(self.pk,))

    class Meta:
        ordering = ["name"]
        verbose_name = _("Category")
        verbose_name_plural = _("Categories")
