From patchwork Wed Nov 7 03:45:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simo Sorce X-Patchwork-Id: 197616 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 531A72C018B for ; Wed, 7 Nov 2012 14:45:14 +1100 (EST) Received: from mail.samba.org (fn.samba.org [216.83.154.106]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 955852C0095 for ; Wed, 7 Nov 2012 14:45:11 +1100 (EST) Received: from pico.ipa.ssimo.org (localhost [127.0.0.1]) by mail.samba.org (Postfix) with ESMTP id A1CE9AD520 for ; Tue, 6 Nov 2012 20:45:08 -0700 (MST) From: Simo Sorce To: patchwork@lists.ozlabs.org Subject: [PATCH] Allow to download public bundle as mbox Date: Tue, 6 Nov 2012 22:45:08 -0500 Message-Id: <1352259908-28369-1-git-send-email-idra@samba.org> X-Mailer: git-send-email 1.7.11.7 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Downloading single patches anonimously is allowed, we may as well allow downloading public bundles as mboxes. This patch also changes the file name to be bundle--.mbox so that the file name is unique even if bundle names are reused. Signed-off-by: Simo Sorce --- apps/patchwork/urls.py | 2 ++ apps/patchwork/views/bundle.py | 18 +++++++++++++----- templates/patchwork/bundle-public.html | 2 ++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/apps/patchwork/urls.py b/apps/patchwork/urls.py index 10fc3b9..3209830 100644 --- a/apps/patchwork/urls.py +++ b/apps/patchwork/urls.py @@ -67,6 +67,8 @@ urlpatterns = patterns('', # public view for bundles (r'^bundle/(?P[^/]*)/(?P[^/]*)/$', 'patchwork.views.bundle.public'), + (r'^bundle/(?P[^/]*)/(?P[^/]*)/mbox/$', + 'patchwork.views.bundle.public_mbox'), (r'^confirm/(?P[0-9a-f]+)/$', 'patchwork.views.confirm'), 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 diff --git a/templates/patchwork/bundle-public.html b/templates/patchwork/bundle-public.html index 3590c46..4947a7e 100644 --- a/templates/patchwork/bundle-public.html +++ b/templates/patchwork/bundle-public.html @@ -7,6 +7,8 @@ {% block body %} +Download bundle as mbox + {% include "patchwork/patch-list.html" %} {% endblock %}