Skip to content

Commit

Permalink
Fix projects ordering. (#942)
Browse files Browse the repository at this point in the history
  • Loading branch information
hramezani authored May 18, 2021
1 parent 891b102 commit 12dce96
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions jazzband/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from packaging.version import parse as parse_version
from pkg_resources import safe_name
from requests.exceptions import HTTPError
from sqlalchemy import desc, nullslast
from sqlalchemy import desc, nullsfirst, nullslast
from sqlalchemy.sql.expression import func
from werkzeug.utils import secure_filename

Expand Down Expand Up @@ -77,10 +77,12 @@ def index():

order = request.args.get("order", None)
if order == DEFAULT_ORDER:
criterion = desc(criterion)
criterion = nullslast(desc(criterion))
else:
criterion = nullsfirst(criterion)

projects = Project.query.filter(Project.is_active.is_(True)).order_by(
nullslast(criterion)
criterion
)
return {
"projects": projects,
Expand Down

0 comments on commit 12dce96

Please sign in to comment.