Skip to content

Commit

Permalink
lowercase grant title and sort asc and desc
Browse files Browse the repository at this point in the history
  • Loading branch information
Jer-Sch committed Nov 22, 2021
1 parent eb92b34 commit 89341ba
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +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.db.models.functions import Lower, Reverse
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 @@ -761,8 +761,11 @@ 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 'title' in sort:
if sort[0] == '-':
_grants = _grants.order_by(Lower('title').desc())
else:
_grants = _grants.order_by(Lower('title'))

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

0 comments on commit 89341ba

Please sign in to comment.