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>
# public view for bundles
(r'^bundle/(?P<username>[^/]*)/(?P<bundlename>[^/]*)/$',
'patchwork.views.bundle.public'),
# 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'),
(r'^confirm/(?P<key>[0-9a-f]+)/$', 'patchwork.views.confirm'),
return render_to_response('patchwork/bundle.html', context)
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 = 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
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,
def public(request, username, bundlename):
user = get_object_or_404(User, username = username)
bundle = get_object_or_404(Bundle, name = bundlename, owner = user,
context['bundle'] = bundle
return render_to_response('patchwork/bundle-public.html', context)
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
+<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 %}
{% include "patchwork/patch-list.html" %}
{% endblock %}