summaryrefslogtreecommitdiffstats
path: root/apps/patchwork/views/bundle.py
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2012-11-06 17:45:08 +0000
committerJeremy Kerr <jk@ozlabs.org>2012-12-30 12:36:04 +0800
commit97d47d0e72c576ba3a09e85fc05e1ba6e0fb6d32 (patch)
treee8bbc6986bb014a1397dfdd41aef96e75064c936 /apps/patchwork/views/bundle.py
parent27b72379bf581c8b3d106bfabc67bd82a18edfc7 (diff)
downloadpatchwork-97d47d0e72c576ba3a09e85fc05e1ba6e0fb6d32.tar.bz2
patchwork-97d47d0e72c576ba3a09e85fc05e1ba6e0fb6d32.tar.xz
views/bundle: Allow downloading public bundle as mbox
Downloading single patches anonymously is allowed, we may as well allow downloading public bundles as mboxes. This patch also changes the file name to be bundle-<id>-<name>.mbox so that the file name is unique even if bundle names are reused. Signed-off-by: Simo Sorce <idra@samba.org> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'apps/patchwork/views/bundle.py')
-rw-r--r--apps/patchwork/views/bundle.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/apps/patchwork/views/bundle.py b/apps/patchwork/views/bundle.py
index e418b3a..058153b 100644
--- a/apps/patchwork/views/bundle.py
+++ b/apps/patchwork/views/bundle.py
@@ -168,15 +168,18 @@ def bundle(request, bundle_id):
return render_to_response('patchwork/bundle.html', context)
-@login_required
-def mbox(request, bundle_id):
- bundle = get_object_or_404(Bundle, id = bundle_id)
+def mbox_response(bundle):
response = HttpResponse(mimetype='text/plain')
- response['Content-Disposition'] = 'attachment; filename=bundle-%d.mbox' % \
- bundle.id
+ response['Content-Disposition'] = \
+ 'attachment; filename=bundle-%d-%s.mbox' % (bundle.id, bundle.name)
response.write(bundle.mbox())
return response
+@login_required
+def mbox(request, bundle_id):
+ bundle = get_object_or_404(Bundle, id = bundle_id)
+ return mbox_response(bundle)
+
def public(request, username, bundlename):
user = get_object_or_404(User, username = username)
bundle = get_object_or_404(Bundle, name = bundlename, owner = user,
@@ -191,3 +194,8 @@ def public(request, username, bundlename):
context['bundle'] = bundle
return render_to_response('patchwork/bundle-public.html', context)
+
+def public_mbox(request, username, bundlename):
+ bundle = get_object_or_404(Bundle, name = bundlename, public = True)
+ return mbox_response(bundle)
+ return response