Skip to content

Fix ordering of filter for most recently built project #9992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions readthedocs/projects/filters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import structlog

from django.db.models import Count, F, Max
from django.forms.widgets import HiddenInput
from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -76,14 +75,14 @@ class ProjectSortOrderingFilter(OrderingFilter):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.extra['choices'] = [
(f'-{self.SORT_NAME}', _('Name (descending)')),
(f'-{self.SORT_MODIFIED_DATE}', _('Most recently modified')),
(self.SORT_MODIFIED_DATE, _('Least recently modified')),
(self.SORT_BUILD_DATE, _('Most recently built')),
(f'-{self.SORT_BUILD_DATE}', _('Least recently built')),
(f'-{self.SORT_BUILD_COUNT}', _('Most frequently built')),
(self.SORT_BUILD_COUNT, _('Least frequently built')),
self.extra["choices"] = [
(f"-{self.SORT_NAME}", _("Name (descending)")),
(f"-{self.SORT_MODIFIED_DATE}", _("Most recently modified")),
(self.SORT_MODIFIED_DATE, _("Least recently modified")),
(f"-{self.SORT_BUILD_DATE}", _("Most recently built")),
(self.SORT_BUILD_DATE, _("Least recently built")),
(f"-{self.SORT_BUILD_COUNT}", _("Most frequently built")),
(self.SORT_BUILD_COUNT, _("Least frequently built")),
]

def filter(self, qs, value):
Expand Down