from django.contrib import messages
from django.shortcuts import get_object_or_404
+from django.utils import six
from patchwork.filters import Filters
from patchwork.forms import MultiplePatchForm
if 'Date' not in mail:
mail['Date'] = email.utils.formatdate(utc_timestamp)
+ # NOTE(stephenfin) http://stackoverflow.com/a/28584090/613428
+ if six.PY3:
+ mail = mail.as_bytes(True).decode()
+ else:
+ mail = mail.as_string(True)
+
return mail
(basic_auth and basic_auth.authenticate(request))):
return HttpResponseNotFound()
- mbox = '\n'.join([patch_to_mbox(p).as_string(True)
- for p in bundle.ordered_patches()])
-
response = HttpResponse(content_type='text/plain')
response['Content-Disposition'] = \
'attachment; filename=bundle-%d-%s.mbox' % (bundle.id, bundle.name)
+ response.write('\n'.join(
+ [patch_to_mbox(p) for p in bundle.ordered_patches()]))
- response.write(mbox)
return response
from django.http import HttpResponseForbidden
from django.http import HttpResponseRedirect
from django.shortcuts import render, get_object_or_404
-from django.utils import six
from patchwork.forms import PatchForm, CreateBundleForm
from patchwork.models import Patch, Project, Bundle, Submission
response.write(patch.diff)
response['Content-Disposition'] = 'attachment; filename=' + \
patch.filename.replace(';', '').replace('\n', '')
+
return response
def patch_mbox(request, patch_id):
patch = get_object_or_404(Patch, id=patch_id)
response = HttpResponse(content_type="text/plain")
- # NOTE(stephenfin) http://stackoverflow.com/a/28584090/613428
- if six.PY3:
- response.write(patch_to_mbox(patch).as_bytes(True).decode())
- else:
- response.write(patch_to_mbox(patch).as_string(True))
+ response.write(patch_to_mbox(patch))
response['Content-Disposition'] = 'attachment; filename=' + \
patch.filename.replace(';', '').replace('\n', '')
+
return response