]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
views: Use context dictionaries in 'project'
authorStephen Finucane <stephen.finucane@intel.com>
Tue, 15 Mar 2016 21:17:22 +0000 (21:17 +0000)
committerStephen Finucane <stephen.finucane@intel.com>
Fri, 25 Mar 2016 11:24:34 +0000 (11:24 +0000)
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@intel.com>
Tested-by: Andy Doan <andy.doan@linaro.org>
patchwork/templates/patchwork/project.html
patchwork/views/project.py

index 28c8da31da19110db842518a88b20e531cc0949e..ffea25ef0e149b8ecc947ed7a718a9e4189e5b9e 100644 (file)
@@ -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 %}"
index 5bc34e9beea9fa3d380eca3b67496a5aed5339a8..ea876b337d2b30d11476dfab6b5131fe85f8039c 100644 (file)
 
 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)