From e12b20a7bb2aa034e3bad7023067746a0c8893b7 Mon Sep 17 00:00:00 2001 From: Bishal <69814108+CodeWithBishal@users.noreply.github.com> Date: Sun, 10 Dec 2023 18:22:34 +0530 Subject: [PATCH] Fix #1640 Pagination Added --- website/templates/new_home.html | 25 ++++++++++++++++++++++++- website/views.py | 9 +++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/website/templates/new_home.html b/website/templates/new_home.html index 9813db8bd..d0d821b36 100644 --- a/website/templates/new_home.html +++ b/website/templates/new_home.html @@ -6,11 +6,34 @@ grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); } -
Find bugs, earn points, prize and cash!
+
Find bugs, earn points, prize and cash!
{% include '_report_widget.html' %} {% for bug in bugs %} {% include '_bug.html' %} {% endfor %}
+
+
+ {% if bugs.has_previous %} + First + {% else %} + + {% endif %} + {% for num in bugs.paginator.page_range %} + {% if num == bugs.number %} + + {% elif num > bugs.number|add:"-5" and num < bugs.number|add:"5" %} + {{num}} + {% endif %} + {% endfor %} + {% if bugs.has_next %} + Last + {% else %} + + {% endif %} +
Page {{ bugs.number }} of {{ bugs.paginator.num_pages }}
+
+
{% endblock %} diff --git a/website/views.py b/website/views.py index 43b7c6cf3..85454c11c 100644 --- a/website/views.py +++ b/website/views.py @@ -188,12 +188,17 @@ def newhome(request, template="new_home.html"): except: pass - bugs=Issue.objects.exclude(Q(is_hidden=True) & ~Q(user_id=request.user.id)) + bugs=Issue.objects.exclude(Q(is_hidden=True) & ~Q(user_id=request.user.id)).all() bugs_screenshots = {} for bug in bugs: bugs_screenshots[bug] = IssueScreenshot.objects.filter(issue=bug)[0:3] + paginator = Paginator(bugs, 7) + page_number = request.GET.get('page') + print(page_number) + page_obj = paginator.get_page(page_number) + # latest_hunts_filter = request.GET.get("latest_hunts",None) # bug_count = Issue.objects.all().count() @@ -237,7 +242,7 @@ def newhome(request, template="new_home.html"): context = { - "bugs": bugs, + "bugs": page_obj, "bugs_screenshots" : bugs_screenshots, # "server_url": request.build_absolute_uri('/'), # "activities": activities,