]> git.ipfire.org Git - ipfire.org.git/commitdiff
dnsbl: Allow to go backwards in history
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 31 Dec 2025 14:36:28 +0000 (14:36 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 31 Dec 2025 14:36:28 +0000 (14:36 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/dnsbl.py
src/templates/dnsbl/lists/history.html
src/web/dnsbl.py

index 62bb52135a6f3c66a53e400ef49756451e985cec..3f590827a3cead4c75cd7bc2655ca2558342cebd 100644 (file)
@@ -242,12 +242,12 @@ class List(Model):
 
        # History
 
-       async def get_history(self, limit=None):
+       async def get_history(self, before=None, limit=None):
                """
                        Fetches the history of this list
                """
                response = await self._backend.dnsbl._fetch(
-                       "/lists/%s/history" % self.slug, args={ "limit" : limit },
+                       "/lists/%s/history" % self.slug, args={ "before" : before, "limit" : limit },
                )
 
                return [History(self._backend, **data) for data in response]
index e77ce5b13e9703b17d6b09df26603e1c486226f6..fa281920c0e7383f47f183be8ec94929626cb65b 100644 (file)
@@ -10,6 +10,8 @@
 {% block title %}{{ _("IPFire DNSBL") }} - {{ list }} - {{ _("History") }}{% end block %}
 
 {% block container %}
+       {% import urllib.parse %}
+
        <section class="hero is-dark">
                <div class="hero-body">
                        <div class="container">
                        </div>
                </section>
        {% end %}
+
+       {# Pagination #}
+       <section class="section">
+               <div class="container">
+                       <nav class="pagination" role="navigation" aria-label="pagination">
+                               {# Find the oldest timestamp #}
+                               {% set before = min(e.ts for e in history) %}
+
+                               <a class="pagination-next"
+                                               href="/dnsbl/lists/{{ list.slug }}/history?before={{ urllib.parse.quote(before.isoformat()) }}">
+                                       {{ _("Older") }} &raquo;
+                               </a>
+                       </nav>
+               </div>
+       </section>
 {% end block %}
index 58360111fddbc7a7e3a97640fbe70c68b001dbb8..3cbbe364c6d317585685e81e14ac734c78d3926b 100644 (file)
@@ -40,7 +40,10 @@ class ListHistoryHandler(base.AnalyticsMixin, BaseHandler):
                        raise tornado.web.HTTPError(404, "Could not find list '%s'" % slug)
 
                # Fetch the history
-               history = await list.get_history(limit=10)
+               history = await list.get_history(
+                       before = self.get_argument("before", None),
+                       limit  = 10,
+               )
 
                # Render the page
                self.render("dnsbl/lists/history.html", list=list, history=history)