]> git.ozlabs.org Git - patchwork/commitdiff
views/bundle: Allow downloading public bundle as mbox
authorSimo Sorce <idra@samba.org>
Tue, 6 Nov 2012 17:45:08 +0000 (17:45 +0000)
committerJeremy Kerr <jk@ozlabs.org>
Sun, 30 Dec 2012 04:36:04 +0000 (12:36 +0800)
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>
apps/patchwork/urls.py
apps/patchwork/views/bundle.py
templates/patchwork/bundle-public.html

index 10fc3b900d9653188f6d4ac6901a54599d8f2048..320983032f85a74a5e88731a82a3984a26a74ad5 100644 (file)
@@ -67,6 +67,8 @@ urlpatterns = patterns('',
     # public view for bundles
     (r'^bundle/(?P<username>[^/]*)/(?P<bundlename>[^/]*)/$',
                                 'patchwork.views.bundle.public'),
+    (r'^bundle/(?P<username>[^/]*)/(?P<bundlename>[^/]*)/mbox/$',
+                                'patchwork.views.bundle.public_mbox'),
 
     (r'^confirm/(?P<key>[0-9a-f]+)/$', 'patchwork.views.confirm'),
 
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
index 3590c4624bc4e73492cba2efc9aa00b67b189b5c..181e2112d6ccbddd97dec2269aad563afa9c9ed3 100644 (file)
@@ -7,6 +7,8 @@
 
 {% block body %}
 
+<a href="{% url patchwork.views.bundle.public_mbox username=bundle.owner.username bundlename=bundle.name %}">Download</a> bundle as mbox
+
 {% include "patchwork/patch-list.html" %}
 
 {% endblock %}