Add multilines description

This commit is contained in:
loulous27 2025-11-28 21:18:49 +01:00
parent 1492c803a8
commit 5ba81ec6f6
2 changed files with 12 additions and 5 deletions

View file

@ -18,7 +18,13 @@ class MultipleFileInput(forms.ClearableFileInput):
class MultipleFileField(forms.FileField):
allowed_extensions = ['jpg', 'jpeg', 'png', 'gif', 'tiff'] # Specify allowed extensions here
allowed_extensions = [
"jpg",
"jpeg",
"png",
"gif",
"tiff",
] # Specify allowed extensions here
def __init__(self, *args, **kwargs):
kwargs.setdefault(
@ -46,7 +52,7 @@ class MultipleFileField(forms.FileField):
cleaned_file = single_file_clean(file, initial)
# Check the file extension
extension = file.name.split('.')[-1].lower()
extension = file.name.split(".")[-1].lower()
if extension not in self.allowed_extensions:
raise forms.ValidationError(
f"{file.name} has an invalid file extension. "
@ -83,8 +89,9 @@ class UploadForm(forms.Form):
required=False,
)
new_gallery_description = forms.CharField(
widget=forms.Textarea(attrs={"rows": 4}),
label=_("Description"),
required=False
required=False,
)
new_gallery_tags = forms.ModelMultipleChoiceField(
Tag.objects.all(),
@ -146,7 +153,7 @@ class UploadForm(forms.Form):
slug=slugify(title),
date_start=self.cleaned_data["new_gallery_date_start"],
date_end=self.cleaned_data["new_gallery_date_end"],
description=self.cleaned_data["new_gallery_description"]
description=self.cleaned_data["new_gallery_description"],
)
for tag in self.cleaned_data["new_gallery_tags"]:
gallery.tags.add(tag)

View file

@ -47,7 +47,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% endfor %}
</p>
{% endif %}
{% if gallery.description %}<p>{{ gallery.description|safe }}</p>{% endif %}
{% if gallery.description %}<p>{{ gallery.description|safe|linebreaksbr }}</p>{% endif %}
<div class="card">
<div class="card-header pb-0 border-bottom-0">