Fix multiple files upload

This commit is contained in:
Alexandre Iooss 2023-08-05 13:42:28 +02:00
parent effb56ef1d
commit b00c2e07fd
2 changed files with 28 additions and 14 deletions

View file

@ -188,10 +188,6 @@ class GalleryUpload(PermissionRequiredMixin, FormView):
permission_required = "photologue.add_gallery"
def form_valid(self, form):
# Upload photos
# We take files from the request to support multiple upload
files = self.request.FILES.getlist("file_field")
# Get or create gallery
gallery = form.get_or_create_gallery()
gallery_year = Path(str(gallery.date_start.year))
@ -200,6 +196,7 @@ class GalleryUpload(PermissionRequiredMixin, FormView):
# Upload pictures
uploaded_photo_name = []
already_exists = 0
files = form.cleaned_data["file_field"]
for photo_file in files:
# Check that we have a valid image
try: