aboutsummaryrefslogtreecommitdiffstats
path: root/bn_django/photos/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'bn_django/photos/views.py')
-rw-r--r--bn_django/photos/views.py56
1 files changed, 28 insertions, 28 deletions
diff --git a/bn_django/photos/views.py b/bn_django/photos/views.py
index 7cc5332..bc8a3a4 100644
--- a/bn_django/photos/views.py
+++ b/bn_django/photos/views.py
@@ -126,31 +126,31 @@ def import_photos(request, thegallery):
dict(form=form, gallery=gallery))
# request,
-@login_required
-def export(request, thegallery):
- """Export a gallery to a zip file and send it to the user.
- """
- # Check if the gallery is valid
- gallery = get_object_or_404(Gallery, pk=thegallery)
-
- # gather up the photos into a new directory
- tmpdir = mkdtemp()
- for photo in gallery.photo_set.all():
- shutil.copy(photo.get_image_filename(),
- tmpdir)
- files = [ os.path.join(tmpdir, ff) for ff in os.listdir(tmpdir) ]
- outfile = NamedTemporaryFile()
- zf = zipfile.ZipFile(outfile, "w",
- compression=zipfile.ZIP_DEFLATED)
- for filename in files:
- zf.write(filename, arcname=os.path.basename(filename))
- zf.close()
- outfile.flush()
- outfile.seek(0)
- shutil.rmtree(tmpdir)
- response = HttpResponse(outfile)
- response['Content-Type'] = "application/zip"
- response['Content-Length'] = str(os.stat(outfile.name)[stat.ST_SIZE])
- response['Content-Disposition'] = "attachment; filename=photos.zip"
- return response
-
+#@login_required
+#def export(request, thegallery):
+ #"""Export a gallery to a zip file and send it to the user.
+ #"""
+ ## Check if the gallery is valid
+ #gallery = get_object_or_404(Gallery, pk=thegallery)
+ #
+ ## gather up the photos into a new directory
+ #tmpdir = mkdtemp()
+ #for photo in gallery.photo_set.all():
+ #shutil.copy(photo.get_image_filename(),
+ #tmpdir)
+ #files = [ os.path.join(tmpdir, ff) for ff in os.listdir(tmpdir) ]
+ #outfile = NamedTemporaryFile()
+ #zf = zipfile.ZipFile(outfile, "w",
+ #compression=zipfile.ZIP_DEFLATED)
+ #for filename in files:
+ #zf.write(filename, arcname=os.path.basename(filename))
+ #zf.close()
+ ##outfile.flush()
+ #outfile.seek(0)
+ #shutil.rmtree(tmpdir)
+ #response = HttpResponse(outfile)
+ #response['Content-Type'] = "application/zip"
+ #response['Content-Length'] = str(os.stat(outfile.name)[stat.ST_SIZE])
+ #response['Content-Disposition'] = "attachment; filename=photos.zip"
+ #return response
+ #