Skip to content

Commit

Permalink
Slightly DRYer list sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
shacker committed Sep 20, 2019
1 parent d07cb30 commit 2b722af
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions todo/views/list_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 2b722af

Please sign in to comment.