Message ID | 1351916566-17431-1-git-send-email-idra@samba.org |
---|---|
State | Superseded |
Headers | show |
Hi Simo, > Downloading single patches anonimously is allowed, we may as well allow > downloading public bundles as mboxes. Sounds good, but: > diff --git a/apps/patchwork/urls.py b/apps/patchwork/urls.py > index 10fc3b9..034fbb3 100644 > --- a/apps/patchwork/urls.py > +++ b/apps/patchwork/urls.py > @@ -67,6 +67,8 @@ urlpatterns = patterns('', > # public view for bundles > (r'^bundle/(?P<username>[^/]*)/(?P<bundlename>[^/]*)/$', > 'patchwork.views.bundle.public'), > + (r'^bundle/(?P<bundlename>[^/]*)/mbox/download/$', > + 'patchwork.views.bundle.public_mbox'), > > (r'^confirm/(?P<key>[0-9a-f]+)/$', 'patchwork.views.confirm'), This will mean that the bundle names will need to be unique amongst all users. How about just adding a "/mbox/" on the end of the public bundle URL? > diff --git a/apps/patchwork/views/bundle.py b/apps/patchwork/views/bundle.py > index e418b3a..d36c790 100644 > --- a/apps/patchwork/views/bundle.py > +++ b/apps/patchwork/views/bundle.py > @@ -191,3 +191,11 @@ def public(request, username, bundlename): > context['bundle'] = bundle > > return render_to_response('patchwork/bundle-public.html', context) > + > +def public_mbox(request, bundlename): > + bundle = get_object_or_404(Bundle, name = bundlename, public = True) > + response = HttpResponse(mimetype='text/plain') > + response['Content-Disposition'] = 'attachment; filename=bundle-%s.mbox' % \ > + bundle.name > + response.write(bundle.mbox()) > + return response Might be good to declare a function which takes a bundle, and returns a HttpResponse, to share the common code between public_mbox() and mbox(). Cheers, Jeremy
On Mon, 2012-11-05 at 21:41 +0800, Jeremy Kerr wrote: > Hi Simo, > > > Downloading single patches anonimously is allowed, we may as well allow > > downloading public bundles as mboxes. > > Sounds good, but: > > > diff --git a/apps/patchwork/urls.py b/apps/patchwork/urls.py > > index 10fc3b9..034fbb3 100644 > > --- a/apps/patchwork/urls.py > > +++ b/apps/patchwork/urls.py > > @@ -67,6 +67,8 @@ urlpatterns = patterns('', > > # public view for bundles > > (r'^bundle/(?P<username>[^/]*)/(?P<bundlename>[^/]*)/$', > > 'patchwork.views.bundle.public'), > > + (r'^bundle/(?P<bundlename>[^/]*)/mbox/download/$', > > + 'patchwork.views.bundle.public_mbox'), > > > > (r'^confirm/(?P<key>[0-9a-f]+)/$', 'patchwork.views.confirm'), > > This will mean that the bundle names will need to be unique amongst all > users. How about just adding a "/mbox/" on the end of the public bundle URL? I did that initially, but for some reason it didn't work, I think urls.py always matched the first one and just returned the page or an error. I also am not sure how to get to the username from the public patch page. > > diff --git a/apps/patchwork/views/bundle.py b/apps/patchwork/views/bundle.py > > index e418b3a..d36c790 100644 > > --- a/apps/patchwork/views/bundle.py > > +++ b/apps/patchwork/views/bundle.py > > @@ -191,3 +191,11 @@ def public(request, username, bundlename): > > context['bundle'] = bundle > > > > return render_to_response('patchwork/bundle-public.html', context) > > + > > +def public_mbox(request, bundlename): > > + bundle = get_object_or_404(Bundle, name = bundlename, public = True) > > + response = HttpResponse(mimetype='text/plain') > > + response['Content-Disposition'] = 'attachment; filename=bundle-%s.mbox' % \ > > + bundle.name > > + response.write(bundle.mbox()) > > + return response > > Might be good to declare a function which takes a bundle, and returns a > HttpResponse, to share the common code between public_mbox() and mbox(). I guess so, if you can help me around with the previous point, I can send a new patch that fixes both. Simo.
diff --git a/apps/patchwork/urls.py b/apps/patchwork/urls.py index 10fc3b9..034fbb3 100644 --- a/apps/patchwork/urls.py +++ b/apps/patchwork/urls.py @@ -67,6 +67,8 @@ urlpatterns = patterns('', # public view for bundles (r'^bundle/(?P<username>[^/]*)/(?P<bundlename>[^/]*)/$', 'patchwork.views.bundle.public'), + (r'^bundle/(?P<bundlename>[^/]*)/mbox/download/$', + 'patchwork.views.bundle.public_mbox'), (r'^confirm/(?P<key>[0-9a-f]+)/$', 'patchwork.views.confirm'), diff --git a/apps/patchwork/views/bundle.py b/apps/patchwork/views/bundle.py index e418b3a..d36c790 100644 --- a/apps/patchwork/views/bundle.py +++ b/apps/patchwork/views/bundle.py @@ -191,3 +191,11 @@ def public(request, username, bundlename): context['bundle'] = bundle return render_to_response('patchwork/bundle-public.html', context) + +def public_mbox(request, bundlename): + bundle = get_object_or_404(Bundle, name = bundlename, public = True) + response = HttpResponse(mimetype='text/plain') + response['Content-Disposition'] = 'attachment; filename=bundle-%s.mbox' % \ + bundle.name + response.write(bundle.mbox()) + return response diff --git a/templates/patchwork/bundle-public.html b/templates/patchwork/bundle-public.html index 3590c46..861b56a 100644 --- a/templates/patchwork/bundle-public.html +++ b/templates/patchwork/bundle-public.html @@ -7,6 +7,8 @@ {% block body %} +<a href="{% url patchwork.views.bundle.public_mbox bundlename=bundle.name %}">Download</a> bundle as mbox + {% include "patchwork/patch-list.html" %} {% endblock %}
Downloading single patches anonimously is allowed, we may as well allow downloading public bundles as mboxes. Signed-off-by: Simo Sorce <idra@samba.org> --- apps/patchwork/urls.py | 2 ++ apps/patchwork/views/bundle.py | 8 ++++++++ templates/patchwork/bundle-public.html | 2 ++ 3 files changed, 12 insertions(+)