Unverified Commit e235dd10 authored by Jelle van der Waa's avatar Jelle van der Waa 🚧 Committed by GitHub
Browse files

Merge pull request #135 from jelly/todolist_sort_complete

todolists: sort todolist on incomplete status
parents 9050c05f bb9bd32a
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.db import models
from django.db.models import Q
from django.db.models.signals import pre_save
from main.models import Arch, Repo, Package
from main.utils import set_created_field
class TodolistManager(models.Manager):
def incomplete(self):
not_done = ((Q(todolistpackage__status=TodolistPackage.INCOMPLETE) |
Q(todolistpackage__status=TodolistPackage.IN_PROGRESS)) &
Q(todolistpackage__removed__isnull=True))
return self.order_by().filter(not_done).distinct()
class Todolist(models.Model):
slug = models.SlugField(max_length=255, unique=True)
old_id = models.IntegerField(null=True, unique=True)
......@@ -27,8 +18,6 @@ class Todolist(models.Model):
last_modified = models.DateTimeField(editable=False)
raw = models.TextField(blank=True)
objects = TodolistManager()
class Meta:
get_latest_by = 'created'
......
......@@ -33,7 +33,8 @@ def get_annotated_todolists(incomplete_only=False):
if incomplete_only:
lists = [l for l in lists if l.incomplete_count > 0]
else:
lists = sorted(lists, key=lambda todolist: todolist.incomplete_count == 0)
return lists
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment