From 01236373aa85ad2564b0f55fdcc0cbdb99387a47 Mon Sep 17 00:00:00 2001 From: Jean-Romain Garnier Date: Wed, 22 Apr 2020 19:10:10 +0200 Subject: [PATCH] Add pagination for machine history results --- logs/templates/logs/machine_history.html | 1 + logs/views.py | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/logs/templates/logs/machine_history.html b/logs/templates/logs/machine_history.html index 93e1817a..5aea5e9d 100644 --- a/logs/templates/logs/machine_history.html +++ b/logs/templates/logs/machine_history.html @@ -66,6 +66,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% endfor %} + {% include 'pagination.html' with list=events %} {% else %}

{% trans "No result" %}

{% endif %} diff --git a/logs/views.py b/logs/views.py index ca75e48f..7e6df54a 100644 --- a/logs/views.py +++ b/logs/views.py @@ -489,16 +489,19 @@ def stats_search_machine_history(request): history_form = MachineHistoryForm(request.GET or None) if history_form.is_valid(): history = MachineHistory() + events = history.get( + history_form.cleaned_data.get("q", ""), + history_form.cleaned_data + ) + max_result = GeneralOption.get_cached_value("search_display_page") + re2o_paginator(request, + events, + max_result) + return render( request, "logs/machine_history.html", - { - "events": - history.get( - history_form.cleaned_data.get("q", ""), - history_form.cleaned_data - ) - }, + { "events": events }, ) return render(request, "logs/search_machine_history.html", {"history_form": history_form})