[PATCH 03/15] views: Use context dictionaries in 'project'
Stephen Finucane
stephen.finucane at intel.com
Fri Mar 25 04:52:48 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 'render_to_response'.
Signed-off-by: Stephen Finucane <stephen.finucane at intel.com>
---
patchwork/templates/patchwork/project.html | 2 +-
patchwork/views/project.py | 34 +++++++++++++++---------------
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/patchwork/templates/patchwork/project.html b/patchwork/templates/patchwork/project.html
index 28c8da3..ffea25e 100644
--- a/patchwork/templates/patchwork/project.html
+++ b/patchwork/templates/patchwork/project.html
@@ -49,7 +49,7 @@
{% endif %}
</table>
-{% if settings.ENABLE_XMLRPC %}
+{% if enable_xmlrpc %}
<p>Sample <a href="{% url 'help' "pwclient/" %}">patchwork
client</a> configuration for this project: <a
href="{% url 'pwclientrc' project.linkname %}"
diff --git a/patchwork/views/project.py b/patchwork/views/project.py
index 5bc34e9..ea876b3 100644
--- a/patchwork/views/project.py
+++ b/patchwork/views/project.py
@@ -19,17 +19,16 @@
from __future__ import absolute_import
+from django.conf import settings
from django.contrib.auth.models import User
from django.core import urlresolvers
from django.http import HttpResponseRedirect
-from django.shortcuts import render_to_response, get_object_or_404
+from django.shortcuts import get_object_or_404, render
-from patchwork.models import Patch, Project
-from patchwork.requestcontext import PatchworkRequestContext
+from patchwork.models import Project
def list(request):
- context = PatchworkRequestContext(request)
projects = Project.objects.all()
if projects.count() == 1:
@@ -37,21 +36,22 @@ def list(request):
urlresolvers.reverse('patch-list',
kwargs={'project_id': projects[0].linkname}))
- context['projects'] = projects
-
- return render_to_response('patchwork/projects.html', context)
+ context = {
+ 'projects': projects,
+ }
+ return render(request, 'patchwork/projects.html', context)
+# TODO(stephenfin): Consistently rename these as list and detail
def project(request, project_id):
- context = PatchworkRequestContext(request)
project = get_object_or_404(Project, linkname=project_id)
- context.project = project
-
- context['maintainers'] = User.objects.filter(
- profile__maintainer_projects=project)
- context['n_patches'] = Patch.objects.filter(project=project,
- archived=False).count()
- context['n_archived_patches'] = Patch.objects.filter(project=project,
- archived=True).count()
- return render_to_response('patchwork/project.html', context)
+ context = {
+ 'project': project,
+ 'maintainers': User.objects.filter(
+ profile__maintainer_projects=project),
+ 'n_patches': project.patch_set.filter(archived=False).count(),
+ 'n_archived_patches': project.patch_set.filter(archived=True).count(),
+ 'enable_xmlrpc': settings.ENABLE_XMLRPC,
+ }
+ return render(request, 'patchwork/project.html', context)
--
2.0.0
More information about the Patchwork
mailing list