mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
unify album name length
This commit is contained in:
@ -16,7 +16,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from io import BytesIO
|
||||
from typing import Self
|
||||
from typing import ClassVar, Self
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.cache import cache
|
||||
@ -203,6 +203,20 @@ class SASAlbumManager(models.Manager):
|
||||
|
||||
|
||||
class Album(SasFile):
|
||||
NAME_MAX_LENGTH: ClassVar[int] = 50
|
||||
"""Maximum length of an album's name.
|
||||
|
||||
[SithFile][core.models.SithFile] have a maximum length
|
||||
of 256 characters.
|
||||
However, this limit is too high for albums.
|
||||
Names longer than 50 characters are harder to read
|
||||
and harder to display on the SAS page.
|
||||
|
||||
It is to be noted, though, that this does not
|
||||
add or modify any db behaviour.
|
||||
It's just a constant to be used in views and forms.
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
|
@ -34,7 +34,7 @@ from sas.models import Album, PeoplePictureRelation, Picture
|
||||
|
||||
class SASForm(forms.Form):
|
||||
album_name = forms.CharField(
|
||||
label=_("Add a new album"), max_length=30, required=False
|
||||
label=_("Add a new album"), max_length=Album.NAME_MAX_LENGTH, required=False
|
||||
)
|
||||
images = MultipleImageField(
|
||||
label=_("Upload images"),
|
||||
@ -353,6 +353,7 @@ class AlbumEditForm(forms.ModelForm):
|
||||
model = Album
|
||||
fields = ["name", "date", "file", "parent", "edit_groups"]
|
||||
|
||||
name = forms.CharField(max_length=Album.NAME_MAX_LENGTH, label=_("file name"))
|
||||
date = forms.DateField(label=_("Date"), widget=SelectDate, required=True)
|
||||
parent = make_ajax_field(Album, "parent", "files", help_text="")
|
||||
edit_groups = make_ajax_field(Album, "edit_groups", "groups", help_text="")
|
||||
|
Reference in New Issue
Block a user