Validate icon slugs
This commit is contained in:
parent
a1c3563348
commit
fd15e60085
1 changed files with 11 additions and 3 deletions
|
@ -3,7 +3,7 @@ import pathlib
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from django.conf import settings
|
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.db import models, transaction
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import gettext as _
|
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)
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||||
name = models.CharField(max_length=64, default=_("Account"), verbose_name=_("Name"))
|
name = models.CharField(max_length=64, default=_("Account"), verbose_name=_("Name"))
|
||||||
icon = models.CharField(
|
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):
|
def __str__(self):
|
||||||
|
@ -76,7 +79,12 @@ class Category(CustomModel):
|
||||||
name = models.CharField(
|
name = models.CharField(
|
||||||
max_length=64, default=_("Category"), verbose_name=_("Name")
|
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"))
|
budget = models.BooleanField(default=True, verbose_name=_("Budget"))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|
Loading…
Reference in a new issue