Skip to content

Commit cd04e11

Browse files
author
Patrick Gan
committed
Update ordering of projects in project picker page
1 parent b5ced60 commit cd04e11

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

rca/projects/models.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,14 @@ def _format_projects(self, projects):
485485
return projects_formatted
486486

487487
def get_base_queryset(self):
488-
return ProjectPage.objects.child_of(self).live().order_by("title")
488+
# Projects with an empty `end_date` shows first.
489+
# This is followed by projects with an end date, with most recent date first.
490+
# If two projects have the same end date, it's based on the last published date.
491+
return (
492+
ProjectPage.objects.child_of(self)
493+
.live()
494+
.order_by(models.F("end_date").desc(nulls_first=True), "-last_published_at")
495+
)
489496

490497
def modify_results(self, paginator_page, request):
491498
for obj in paginator_page.object_list:

0 commit comments

Comments
 (0)