]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/views/bundle.py
views/bundle: Allow downloading public bundle as mbox
[patchwork] / apps / patchwork / views / bundle.py
index e418b3ae476c6aa4a0c94f81d6778c3640d38f12..058153beeefc70a748ed089defba95e53270de71 100644 (file)
@@ -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