From 2b722afb8ab8c514c1e55821287ff68b3b21d066 Mon Sep 17 00:00:00 2001 From: Scot Hacker Date: Thu, 19 Sep 2019 22:41:45 -0700 Subject: [PATCH] Slightly DRYer list sorting --- todo/views/list_lists.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/todo/views/list_lists.py b/todo/views/list_lists.py index 45a9836..f03a866 100644 --- a/todo/views/list_lists.py +++ b/todo/views/list_lists.py @@ -27,12 +27,9 @@ def list_lists(request) -> HttpResponse: ) # Superusers see all lists - if request.user.is_superuser: - lists = TaskList.objects.all().order_by("group__name", "name") - else: - lists = TaskList.objects.filter(group__in=request.user.groups.all()).order_by( - "group__name", "name" - ) + lists = TaskList.objects.all().order_by("group__name", "name") + if not request.user.is_superuser: + lists = lists.filter(group__in=request.user.groups.all()) list_count = lists.count()