From 2c95e10949677b4e951f53aaec2961aae0ba34de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Angel=20Gordi=C3=A1n?= Date: Mon, 30 Nov 2020 00:35:48 -0600 Subject: [PATCH] Fix display of some collections (#7960) --- app/grants/views.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/grants/views.py b/app/grants/views.py index c91b3bf238d..c1b3a916c21 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -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 @@ -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, @@ -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, })