Skip to content

Commit

Permalink
Fix display of some collections (#7960)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoek1 authored Nov 30, 2020
1 parent f6c4fbe commit 2c95e10
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from django.contrib.auth.decorators import login_required
from django.contrib.contenttypes.models import ContentType
from django.contrib.humanize.templatetags.humanize import intword, naturaltime
from django.core.paginator import Paginator
from django.core.paginator import Paginator, EmptyPage
from django.db import connection
from django.db.models import Avg, Count, Max, Q, Subquery
from django.http import Http404, HttpResponse, JsonResponse
Expand Down Expand Up @@ -629,6 +629,13 @@ def get_grants(request):
grant_json = grant.repr(request.user, request.build_absolute_uri)
grants_array.append(grant_json)

has_next = False
if paginator:
try:
has_next = paginator.page(page).has_next()
except EmptyPage:
pass

return JsonResponse({
'grant_types': get_grant_clr_types(clr_round, _grants, network) if clr_round else get_grant_type_cache(network),
'current_type': grant_type,
Expand All @@ -640,7 +647,7 @@ def get_grants(request):
'is_authenticated': request.user.is_authenticated
},
'contributions': contributions_by_grant,
'has_next': paginator.page(page).has_next() if paginator else False,
'has_next': has_next,
'count': paginator.count if paginator else 0,
'num_pages': paginator.num_pages if paginator else 0,
})
Expand Down

0 comments on commit 2c95e10

Please sign in to comment.