From: Stephen Finucane Date: Thu, 18 Feb 2016 21:26:55 +0000 (+0000) Subject: views: Redirect when only one TODO exists X-Git-Tag: v1.1.0~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a31ec6e577bd36d50a2787832915ab51f062168;p=thirdparty%2Fpatchwork.git views: Redirect when only one TODO exists At the moment, the page listing all TODOs will display like the page detailing a single TODO. This is misleading. Instead, use the same approach as the index page, where the user is automatically redirected to the appropriate project's page when only one project exists. Signed-off-by: Stephen Finucane --- diff --git a/patchwork/views/user.py b/patchwork/views/user.py index 78cb0d77..720b32c3 100644 --- a/patchwork/views/user.py +++ b/patchwork/views/user.py @@ -24,7 +24,7 @@ from django.contrib.auth.decorators import login_required from django.contrib.sites.models import Site from django.conf import settings from django.core.mail import send_mail -import django.core.urlresolvers +from django.core import urlresolvers from django.http import HttpResponseRedirect from django.shortcuts import render_to_response, get_object_or_404 from django.template.loader import render_to_string @@ -184,7 +184,7 @@ def unlink(request, person_id): person.user = None person.save() - url = django.core.urlresolvers.reverse('user-profile') + url = urlresolvers.reverse('user-profile') return HttpResponseRedirect(url) @@ -200,7 +200,10 @@ def todo_lists(request): todo_lists.append({'project': project, 'n_patches': patches.count()}) if len(todo_lists) == 1: - return todo_list(request, todo_lists[0]['project'].linkname) + return HttpResponseRedirect( + urlresolvers.reverse( + 'user-todo', + kwargs={'project_id': todo_lists[0]['project'].linkname})) context = PatchworkRequestContext(request) context['todo_lists'] = todo_lists