Add multilines description
This commit is contained in:
parent
1492c803a8
commit
5ba81ec6f6
2 changed files with 12 additions and 5 deletions
|
|
@ -18,7 +18,13 @@ class MultipleFileInput(forms.ClearableFileInput):
|
||||||
|
|
||||||
|
|
||||||
class MultipleFileField(forms.FileField):
|
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):
|
def __init__(self, *args, **kwargs):
|
||||||
kwargs.setdefault(
|
kwargs.setdefault(
|
||||||
|
|
@ -46,7 +52,7 @@ class MultipleFileField(forms.FileField):
|
||||||
cleaned_file = single_file_clean(file, initial)
|
cleaned_file = single_file_clean(file, initial)
|
||||||
|
|
||||||
# Check the file extension
|
# Check the file extension
|
||||||
extension = file.name.split('.')[-1].lower()
|
extension = file.name.split(".")[-1].lower()
|
||||||
if extension not in self.allowed_extensions:
|
if extension not in self.allowed_extensions:
|
||||||
raise forms.ValidationError(
|
raise forms.ValidationError(
|
||||||
f"{file.name} has an invalid file extension. "
|
f"{file.name} has an invalid file extension. "
|
||||||
|
|
@ -83,8 +89,9 @@ class UploadForm(forms.Form):
|
||||||
required=False,
|
required=False,
|
||||||
)
|
)
|
||||||
new_gallery_description = forms.CharField(
|
new_gallery_description = forms.CharField(
|
||||||
|
widget=forms.Textarea(attrs={"rows": 4}),
|
||||||
label=_("Description"),
|
label=_("Description"),
|
||||||
required=False
|
required=False,
|
||||||
)
|
)
|
||||||
new_gallery_tags = forms.ModelMultipleChoiceField(
|
new_gallery_tags = forms.ModelMultipleChoiceField(
|
||||||
Tag.objects.all(),
|
Tag.objects.all(),
|
||||||
|
|
@ -146,7 +153,7 @@ class UploadForm(forms.Form):
|
||||||
slug=slugify(title),
|
slug=slugify(title),
|
||||||
date_start=self.cleaned_data["new_gallery_date_start"],
|
date_start=self.cleaned_data["new_gallery_date_start"],
|
||||||
date_end=self.cleaned_data["new_gallery_date_end"],
|
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"]:
|
for tag in self.cleaned_data["new_gallery_tags"]:
|
||||||
gallery.tags.add(tag)
|
gallery.tags.add(tag)
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% 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">
|
||||||
<div class="card-header pb-0 border-bottom-0">
|
<div class="card-header pb-0 border-bottom-0">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue