Pathlib less in zip download
This commit is contained in:
parent
c50f0e5cfa
commit
1ea7e8fc29
1 changed files with 4 additions and 4 deletions
|
|
@ -183,10 +183,10 @@ class GalleryDownload(LoginRequiredMixin, DetailView):
|
|||
# Create zip file with pictures
|
||||
gallery = self.get_object()
|
||||
|
||||
gallery_year = Path("/photos/" + str(+gallery.date_start.year))
|
||||
gallery_zip = gallery_year / (gallery.slug + ".zip")
|
||||
gallery_year = os.path.join("/photos/", str(gallery.date_start.year))
|
||||
gallery_zip = os.path.join(gallery_year, (gallery.slug + ".zip"))
|
||||
|
||||
with open(settings.MEDIA_ROOT + str(gallery_zip), "wb") as zip_bytes: # I hate pathlib
|
||||
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))
|
||||
|
|
@ -196,7 +196,7 @@ class GalleryDownload(LoginRequiredMixin, DetailView):
|
|||
# Return the path to it
|
||||
|
||||
return redirect(
|
||||
settings.MEDIA_URL + str(gallery_zip).replace("\\", "/")
|
||||
os.path.join(settings.MEDIA_URL, str(gallery_zip)).replace("\\", "/")
|
||||
) # windows fix
|
||||
# Return zip file
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue