Commit 04e66891 authored by Stephen Finucane's avatar Stephen Finucane Committed by Jeremy Kerr
Browse files

views: Replace 'mimetype' with 'content_type'

Passing 'mimetype' to 'HttpResponse' is deprecated in 1.6 and
removed in Django 1.7. Among other things, this causes some unit
tests to fail when using Django 1.7. Its replacement - 'content_type'
- is available in Django 1.5+. This can be seen here:

    https://docs.djangoproject.com/en/1.5/ref/request-response/#django.http.HttpResponse.__init__



This is therefore a like-for-like replacement.
Signed-off-by: default avatarStephen Finucane <stephenfinucane@hotmail.com>
Signed-off-by: default avatarJeremy Kerr <jk@ozlabs.org>
parent a48f76a2
......@@ -47,14 +47,14 @@ def pwclientrc(request, project_id):
context['scheme'] = 'https'
else:
context['scheme'] = 'http'
response = HttpResponse(mimetype = "text/plain")
response = HttpResponse(content_type = "text/plain")
response['Content-Disposition'] = 'attachment; filename=.pwclientrc'
response.write(render_to_string('patchwork/pwclientrc', context))
return response
def pwclient(request):
context = PatchworkRequestContext(request)
response = HttpResponse(mimetype = "text/x-python")
response = HttpResponse(content_type = "text/x-python")
response['Content-Disposition'] = 'attachment; filename=pwclient'
response.write(render_to_string('patchwork/pwclient', context))
return response
......@@ -87,7 +87,7 @@ def confirm(request, key):
def submitter_complete(request):
search = request.GET.get('q', '')
limit = request.GET.get('l', None)
response = HttpResponse(mimetype = "text/plain")
response = HttpResponse(content_type = "text/plain")
if len(search) <= 3:
return response
......
......@@ -196,7 +196,7 @@ def mbox(request, username, bundlename):
mbox = '\n'.join([patch_to_mbox(p).as_string(True)
for p in bundle.ordered_patches()])
response = HttpResponse(mimetype='text/plain')
response = HttpResponse(content_type='text/plain')
response['Content-Disposition'] = \
'attachment; filename=bundle-%d-%s.mbox' % (bundle.id, bundle.name)
......
......@@ -85,7 +85,7 @@ def patch(request, patch_id):
def content(request, patch_id):
patch = get_object_or_404(Patch, id=patch_id)
response = HttpResponse(mimetype="text/x-patch")
response = HttpResponse(content_type="text/x-patch")
response.write(patch.content)
response['Content-Disposition'] = 'attachment; filename=' + \
patch.filename().replace(';', '').replace('\n', '')
......@@ -93,7 +93,7 @@ def content(request, patch_id):
def mbox(request, patch_id):
patch = get_object_or_404(Patch, id=patch_id)
response = HttpResponse(mimetype="text/plain")
response = HttpResponse(content_type="text/plain")
response.write(patch_to_mbox(patch).as_string(True))
response['Content-Disposition'] = 'attachment; filename=' + \
patch.filename().replace(';', '').replace('\n', '')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment