diff mbox

views: Redirect when only one TODO exists

Message ID 1455831395-8612-1-git-send-email-stephen.finucane@intel.com
State Accepted
Headers show

Commit Message

Stephen Finucane Feb. 18, 2016, 9:36 p.m. UTC
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 <stephen.finucane@intel.com>
---
 patchwork/views/user.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Stephen Finucane Feb. 24, 2016, 8:58 p.m. UTC | #1
On 18 Feb 21:36, Stephen Finucane wrote:
> 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 <stephen.finucane@intel.com>

Merged.
diff mbox

Patch

diff --git a/patchwork/views/user.py b/patchwork/views/user.py
index 78cb0d7..720b32c 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