diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-06-10 11:37:25 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-06-10 11:57:25 +0800 |
commit | 67181f5c929018d5304732969f0811795c13ea37 (patch) | |
tree | b3a795c3cb45fe9579f8d84e6fddfe50cfdc4b10 /apps/patchwork/views/bundle.py | |
parent | e7353352191516e45d21f9814375a92cc7f602dc (diff) | |
download | patchwork-67181f5c929018d5304732969f0811795c13ea37.tar.bz2 patchwork-67181f5c929018d5304732969f0811795c13ea37.tar.xz |
views: Move mbox handling from models to views
Mbox generation is related to views, not the models themselves. This
change creates a patch_to_mbox function in the views/ directory, which
the actual view handlers use instead of Patch.mbox().
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'apps/patchwork/views/bundle.py')
-rw-r--r-- | apps/patchwork/views/bundle.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/apps/patchwork/views/bundle.py b/apps/patchwork/views/bundle.py index 7a120dd..c99e322 100644 --- a/apps/patchwork/views/bundle.py +++ b/apps/patchwork/views/bundle.py @@ -26,7 +26,7 @@ import django.core.urlresolvers from patchwork.models import Patch, Bundle, BundlePatch, Project from patchwork.utils import get_patch_ids from patchwork.forms import BundleForm, DeleteBundleForm -from patchwork.views import generic_list +from patchwork.views import generic_list, patch_to_mbox from patchwork.filters import DelegateFilter @login_required @@ -193,10 +193,14 @@ def mbox(request, username, bundlename): if not (request.user == bundle.owner or bundle.public): return HttpResponseNotFound() + mbox = '\n'.join([patch_to_mbox(p).as_string(True) + for p in bundle.ordered_patches()]) + response = HttpResponse(mimetype='text/plain') response['Content-Disposition'] = \ 'attachment; filename=bundle-%d-%s.mbox' % (bundle.id, bundle.name) - response.write(bundle.mbox()) + + response.write(mbox) return response @login_required |