def photoset_zip(request, id, template_name="photos/photo-set/zip.html"): """ Generate zip file for the entire photo set for admins only. """ photo_set = get_object_or_404(PhotoSet, id=id) #admin only if not request.user.profile.is_superuser: raise Http403 file_path = "" task_id = "" if not getattr(settings, 'CELERY_IS_ACTIVE', None): task = ZipPhotoSetTask() file_path = task.run(photo_set) else: task = ZipPhotoSetTask.delay(photo_set) task_id = task.task_id return render_to_resp(request=request, template_name=template_name, context={ "photo_set": photo_set, "task_id": task_id, "file_path": file_path, })
def photoset_zip(request, id, template_name="photos/photo-set/zip.html"): """ Generate zip file for the entire photo set for admins only. """ photo_set = get_object_or_404(PhotoSet, id=id) #admin only if not request.user.profile.is_superuser: raise Http403 file_path = "" task_id = "" if not settings.CELERY_IS_ACTIVE: task = ZipPhotoSetTask() file_path = task.run(photo_set) else: task = ZipPhotoSetTask.delay(photo_set) task_id = task.task_id return render_to_response(template_name, { "photo_set": photo_set, "task_id":task_id, "file_path":file_path, }, context_instance=RequestContext(request))