From 5dd59bb5987493168ef2020c20009c762a558ca7 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 8 Feb 2026 16:35:43 +0000 Subject: [PATCH] dbl: Move reports to the list page Signed-off-by: Michael Tremer --- Makefile.am | 2 +- src/templates/dbl/lists/reports.html | 113 ------------------------- src/templates/dbl/lists/show.html | 29 +++---- src/templates/dbl/modules/reports.html | 31 +++++++ src/web/__init__.py | 2 +- src/web/dbl.py | 24 ++---- 6 files changed, 55 insertions(+), 146 deletions(-) delete mode 100644 src/templates/dbl/lists/reports.html create mode 100644 src/templates/dbl/modules/reports.html diff --git a/Makefile.am b/Makefile.am index b4954ae1..60273ecf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -201,13 +201,13 @@ templates_dbldir = $(templatesdir)/dbl templates_dbl_lists_DATA = \ src/templates/dbl/lists/domain.html \ src/templates/dbl/lists/history.html \ - src/templates/dbl/lists/reports.html \ src/templates/dbl/lists/show.html templates_dbl_listsdir = $(templates_dbldir)/lists templates_dbl_modules_DATA = \ src/templates/dbl/modules/lists.html \ + src/templates/dbl/modules/reports.html \ src/templates/dbl/modules/sources.html \ src/templates/dbl/modules/submit-report.html diff --git a/src/templates/dbl/lists/reports.html b/src/templates/dbl/lists/reports.html deleted file mode 100644 index 457498d4..00000000 --- a/src/templates/dbl/lists/reports.html +++ /dev/null @@ -1,113 +0,0 @@ -{% extends "../../base.html" %} - -{% block head %} - {% module OpenGraph( - title=_("IPFire DBL - %s - Reports") % list, - description=list.description, - ) %} -{% end block %} - -{% block title %}{{ _("IPFire DBL") }} - {{ list }} - {{ _("Reports") }}{% end block %} - -{% block container %} -
-
-
- - -

- {{ _("Reports: %s") % list }} -

-
-
-
- -
-
-
- {{ _("Pending Reports") }} -
- - {# Show any pending reports #} - {% if reports %} - {% for report in reports %} -
-
-
-
-
-

- - {{ report }} - -

- -

- {{ _("Submitted %(when)s by %(who)s") % { - "when" : locale.format_date(report.reported_at), - "who" : report.reported_by, - } }} -

-
- - {# Comment #} - {% if report.comment %} -
-
{{ report.comment }}
-
- {% end %} -
-
-
-
- {% end %} - - {# Show a note if we don't have any pending reports #} - {% else %} -
- {{ _("There are currently no pending reports for this list") }} -
- {% end %} -
-
- -
-
-
- {{ _("See Something? Say Something") }} -
- -
- Spot something that should be listed? Send it our way. -
- - - {{ _("Submit a Report") }} - -
-
-{% end block %} diff --git a/src/templates/dbl/lists/show.html b/src/templates/dbl/lists/show.html index 4d0151c9..a6d5cfcd 100644 --- a/src/templates/dbl/lists/show.html +++ b/src/templates/dbl/lists/show.html @@ -72,25 +72,9 @@ - {# Information #}
+ {# Reports #} + {% if reports %} +
+
+

+ {{ _("Open Reports") }} +

+ + {% module DBLReports(reports) %} +
+
+ {% end %} + {# Sources #} {% if sources %}
diff --git a/src/templates/dbl/modules/reports.html b/src/templates/dbl/modules/reports.html new file mode 100644 index 00000000..f1d96035 --- /dev/null +++ b/src/templates/dbl/modules/reports.html @@ -0,0 +1,31 @@ +{% for report in reports %} +
+
+
+
+
+

+ + {{ report }} + +

+ +

+ {{ _("Submitted %(when)s by %(who)s") % { + "when" : locale.format_date(report.reported_at), + "who" : report.reported_by, + } }} +

+
+ + {# Comment #} + {% if report.comment %} +
+
{{ report.comment }}
+
+ {% end %} +
+
+
+
+{% end %} diff --git a/src/web/__init__.py b/src/web/__init__.py index 064b12a6..45e13f0b 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -86,6 +86,7 @@ class Application(tornado.web.Application): # DBL "DBLLists" : dbl.ListsModule, + "DBLReports" : dbl.ReportsModule, "DBLSources" : dbl.SourcesModule, "DBLSubmitReport" : dbl.SubmitReportModule, @@ -224,7 +225,6 @@ class Application(tornado.web.Application): (r"/dbl/lists/([\w\-]+)", dbl.ListHandler), (r"/dbl/lists/([\w\-]+)/domains/(.*)", dbl.ListDomainHandler), (r"/dbl/lists/([\w\-]+)/history", dbl.ListHistoryHandler), - (r"/dbl/lists/([\w\-]+)/reports", dbl.ListReportsHandler), (r"/dbl/report", dbl.SubmitReportHandler), (r"/dbl/reports/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})", dbl.ReportHandler), (r"/dbl/search", dbl.SearchHandler), diff --git a/src/web/dbl.py b/src/web/dbl.py index 122f1522..1e2c7583 100644 --- a/src/web/dbl.py +++ b/src/web/dbl.py @@ -45,8 +45,11 @@ class ListHandler(base.AnalyticsMixin, BaseHandler): # Fetch the sources sources = await list.get_sources() + # Fetch any open reports + reports = await list.get_reports(open=True) + # Render the page - self.render("dbl/lists/show.html", list=list, sources=sources) + self.render("dbl/lists/show.html", list=list, sources=sources, reports=reports) class ListHistoryHandler(base.AnalyticsMixin, BaseHandler): @@ -66,20 +69,6 @@ class ListHistoryHandler(base.AnalyticsMixin, BaseHandler): self.render("dbl/lists/history.html", list=list, history=history) -class ListReportsHandler(base.AnalyticsMixin, BaseHandler): - async def get(self, slug): - # Fetch the list - list = await self.backend.dbl.get_list(slug) - if not list: - raise tornado.web.HTTPError(404, "Could not find list '%s'" % slug) - - # Fetch any open reports - reports = await list.get_reports(open=True) - - # Render the page - self.render("dbl/lists/reports.html", list=list, reports=reports) - - class ListDomainHandler(base.AnalyticsMixin, BaseHandler): async def get(self, slug, name): # Fetch the list @@ -198,6 +187,11 @@ class ListsModule(ui_modules.UIModule): return self.render_string("dbl/modules/lists.html", lists=lists) +class ReportsModule(ui_modules.UIModule): + def render(self, reports): + return self.render_string("dbl/modules/reports.html", reports=reports) + + class SourcesModule(ui_modules.UIModule): def render(self, sources): return self.render_string("dbl/modules/sources.html", sources=sources) -- 2.47.3