Skip to content

Commit

Permalink
first attempt at case-insensitive sort
Browse files Browse the repository at this point in the history
  • Loading branch information
Jer-Sch committed Nov 19, 2021
1 parent d462049 commit eb92b34
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from django.core.paginator import EmptyPage, Paginator
from django.db import connection, transaction
from django.db.models import Q, Subquery
from django.db.models.functions import Lower
from django.http import Http404, HttpResponse, JsonResponse
from django.http.response import HttpResponseBadRequest, HttpResponseServerError
from django.shortcuts import get_object_or_404, redirect
Expand Down Expand Up @@ -760,6 +761,9 @@ def get_grants_by_filters(
field_name = f'clr_prediction_curve__{sort_by_index}__2'
_grants = _grants.order_by(f"{order}{field_name}")

elif '-sort' in sort:
_grants = _grants.order_by(Lower(f"{sort}"))

# elif 'random_shuffle' in sort:
# _grants = _grants.order_by('?')

Expand All @@ -769,7 +773,7 @@ def get_grants_by_filters(
_grants = _grants.filter(is_clr_active=True).order_by(f"{sort}")

elif sort.replace('-', '') in [
'weighted_shuffle', 'metadata__upcoming', 'metadata__gem', 'created_on', 'amount_received', 'contribution_count', 'contributor_count', 'last_update', 'title'
'weighted_shuffle', 'metadata__upcoming', 'metadata__gem', 'created_on', 'amount_received', 'contribution_count', 'contributor_count', 'last_update'
]:
print(f"Sort is {sort}")
_grants = _grants.order_by(f"{sort}")
Expand Down

0 comments on commit eb92b34

Please sign in to comment.