Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jelle van der Waa
Archweb
Commits
e235dd10
Unverified
Commit
e235dd10
authored
Aug 11, 2018
by
Jelle van der Waa
🚧
Committed by
GitHub
Aug 11, 2018
Browse files
Merge pull request #135 from jelly/todolist_sort_complete
todolists: sort todolist on incomplete status
parents
9050c05f
bb9bd32a
Changes
2
Hide whitespace changes
Inline
Side-by-side
todolists/models.py
View file @
e235dd10
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'
...
...
todolists/utils.py
View file @
e235dd10
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment