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:
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)