Validate icon slugs

This commit is contained in:
Edgar P. Burkhart 2022-12-29 22:17:55 +01:00
parent a1c3563348
commit fd15e60085
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227

View file

@ -3,7 +3,7 @@ import pathlib
import uuid
from django.conf import settings
from django.core.validators import FileExtensionValidator
from django.core.validators import FileExtensionValidator, validate_slug
from django.db import models, transaction
from django.urls import reverse
from django.utils.translation import gettext as _
@ -34,7 +34,10 @@ class Account(CustomModel):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=64, default=_("Account"), verbose_name=_("Name"))
icon = models.CharField(
max_length=64, default="building-columns", verbose_name=_("Icon")
max_length=64,
default="building-columns",
verbose_name=_("Icon"),
validators=[validate_slug],
)
def __str__(self):
@ -76,7 +79,12 @@ class Category(CustomModel):
name = models.CharField(
max_length=64, default=_("Category"), verbose_name=_("Name")
)
icon = models.CharField(max_length=64, default="folder", verbose_name=_("Icon"))
icon = models.CharField(
max_length=64,
default="folder",
verbose_name=_("Icon"),
validators=[validate_slug],
)
budget = models.BooleanField(default=True, verbose_name=_("Budget"))
def __str__(self):