From 8e0957124fa0a887a3a0108dccc4f2dba0169fc5 Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Wed, 19 Feb 2020 11:50:16 -0800 Subject: [PATCH] Add ability to sort dashboard by modified date This only implemented the backend, so you can pass a GET arg to it to have it sort. The goal will be to have a proper UI for this after the UI refactor, but I want this now :) --- readthedocs/projects/views/private.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/readthedocs/projects/views/private.py b/readthedocs/projects/views/private.py index aa42a2bf85f..946fccfcc61 100644 --- a/readthedocs/projects/views/private.py +++ b/readthedocs/projects/views/private.py @@ -109,7 +109,10 @@ def validate_primary_email(self, user): notification.send() def get_queryset(self): - return Project.objects.dashboard(self.request.user) + sort = self.request.GET.get('sort') + if sort not in ['modified_date', '-modified_date', 'slug', '-slug']: + sort = 'slug' + return Project.objects.dashboard(self.request.user).order_by(sort) def get(self, request, *args, **kwargs): self.validate_primary_email(request.user)