From f5c500d1492bea39c4f1111f90884ff35ec06779 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 21 Aug 2018 11:28:28 +0200 Subject: [PATCH] allow zip files with folders --- patches/photologue-allow-folders.patch | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 patches/photologue-allow-folders.patch diff --git a/patches/photologue-allow-folders.patch b/patches/photologue-allow-folders.patch new file mode 100644 index 0000000..aa34301 --- /dev/null +++ b/patches/photologue-allow-folders.patch @@ -0,0 +1,30 @@ +diff --git a/photologue/forms.py b/photologue/forms.py +index 2b05c17..1a69f88 100644 +--- a/photologue/forms.py ++++ b/photologue/forms.py +@@ -114,16 +114,6 @@ class UploadZipForm(forms.Form): + logger.debug('Ignoring file "{0}".'.format(filename)) + continue + +- if os.path.dirname(filename): +- logger.warning('Ignoring file "{0}" as it is in a subfolder; all images should be in the top ' +- 'folder of the zip.'.format(filename)) +- if request: +- messages.warning(request, +- _('Ignoring file "{filename}" as it is in a subfolder; all images should ' +- 'be in the top folder of the zip.').format(filename=filename), +- fail_silently=True) +- continue +- + data = zip.read(filename) + + if not len(data): +@@ -166,7 +156,7 @@ class UploadZipForm(forms.Form): + continue + + contentfile = ContentFile(data) +- photo.image.save(filename, contentfile) ++ photo.image.save(os.path.basename(filename), contentfile) + photo.save() + photo.sites.add(current_site) + gallery.photos.add(photo)