Fix double slash in gallery zip download URL
All checks were successful
Docker / build (release) Successful in 8s
All checks were successful
Docker / build (release) Successful in 8s
This commit is contained in:
parent
893c56874f
commit
317bad9068
1 changed files with 3 additions and 8 deletions
|
|
@ -202,21 +202,16 @@ class GalleryDownload(LoginRequiredMixin, DetailView):
|
|||
# Create zip file with pictures
|
||||
gallery = self.get_object()
|
||||
|
||||
gallery_year = os.path.join("/photos/", str(gallery.date_start.year))
|
||||
gallery_zip = os.path.join(gallery_year, (gallery.slug + ".zip"))
|
||||
gallery_zip = os.path.join("photos", str(gallery.date_start.year), gallery.slug + ".zip")
|
||||
|
||||
with open(settings.MEDIA_ROOT + gallery_zip, "wb") as zip_bytes:
|
||||
with open(os.path.join(settings.MEDIA_ROOT, gallery_zip), "wb") as zip_bytes:
|
||||
zip_file = zipfile.ZipFile(zip_bytes, "w")
|
||||
for photo in gallery.photos.filter(is_public=True):
|
||||
filename = os.path.basename(os.path.normpath(photo.image.path))
|
||||
zip_file.write(photo.image.path, filename)
|
||||
zip_file.close()
|
||||
|
||||
# Return the path to it
|
||||
|
||||
return redirect(
|
||||
(settings.MEDIA_URL + str(gallery_zip)).replace("\\", "/")
|
||||
) # windows fix
|
||||
return redirect(settings.MEDIA_URL + gallery_zip)
|
||||
# Return zip file
|
||||
|
||||
# response = HttpResponse(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue