[PATCH 05/15] views: Use context dictionaries in 'pwclient'
Stephen Finucane
stephen.finucane at intel.com
Fri Mar 25 04:52:50 AEDT 2016
Remove the use of PatchworkRequestContext in this view as it is not
required and causes a 'RemovedInDjango110Warning' warning. This
requires the use of 'render', rather than a combo of 'response.write'
and 'render_to_string'.
Signed-off-by: Stephen Finucane <stephen.finucane at intel.com>
---
patchwork/views/pwclient.py | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/patchwork/views/pwclient.py b/patchwork/views/pwclient.py
index b3e0052..6fa1c17 100644
--- a/patchwork/views/pwclient.py
+++ b/patchwork/views/pwclient.py
@@ -20,31 +20,32 @@
from __future__ import absolute_import
from django.conf import settings
-from django.http import HttpResponse
-from django.shortcuts import get_object_or_404
-from django.template.loader import render_to_string
+from django.shortcuts import get_object_or_404, render
from patchwork.models import Project
-from patchwork.requestcontext import PatchworkRequestContext
def pwclientrc(request, project_id):
project = get_object_or_404(Project, linkname=project_id)
- context = PatchworkRequestContext(request)
- context.project = project
+
+ context = {
+ 'project': project,
+ }
if settings.FORCE_HTTPS_LINKS or request.is_secure():
context['scheme'] = 'https'
else:
context['scheme'] = 'http'
- response = HttpResponse(content_type="text/plain")
+
+ response = render(request, 'patchwork/pwclientrc', context,
+ 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(content_type="text/x-python")
+ response = render(request, 'patchwork/pwclientrc',
+ content_type='text/x-python')
response['Content-Disposition'] = 'attachment; filename=pwclient'
- response.write(render_to_string('patchwork/pwclient', context))
+
return response
--
2.0.0
More information about the Patchwork
mailing list