From: Michael Tremer Date: Fri, 27 Feb 2026 17:51:22 +0000 (+0000) Subject: dbl: Fetch comments for reports X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cbf7cc676c5716632162ae0caaa42207524947db;p=ipfire.org.git dbl: Fetch comments for reports Signed-off-by: Michael Tremer --- diff --git a/src/backend/dbl.py b/src/backend/dbl.py index c50301cf..63e1e06c 100644 --- a/src/backend/dbl.py +++ b/src/backend/dbl.py @@ -362,9 +362,6 @@ class Report(Model): return False - # Comment - comment : str = "" - # Block? block : bool = True @@ -400,6 +397,44 @@ class Report(Model): "/reports/%s/close" % self.id, method="POST", body=body, ) + # Comments + + async def get_comments(self): + """ + Fetches all comments to this report + """ + response = await self._backend.dbl._fetch( + "/reports/%s/comments" % self.id, + ) + + return [ReportComment(self._backend, **data) for data in response] + + +class ReportComment(Model): + def __str__(self): + return self.comment + + # ID + id: uuid.UUID + + # Created At + created_at : datetime.datetime + + # Created By + created_by : str + + # Deleted At + deleted_at : datetime.datetime | None = None + + # Deleted By + deleted_by : str | None = None + + # Comment + comment: str = "" + + # Points + points: int = 0 + class History(Model): """ diff --git a/src/templates/dbl/reports/show.html b/src/templates/dbl/reports/show.html index 2e586f38..260f1b32 100644 --- a/src/templates/dbl/reports/show.html +++ b/src/templates/dbl/reports/show.html @@ -54,23 +54,6 @@ {% end %} - - {# Comment #} -
- {% if report.comment %} -
-
- {{ _("%s commented:") % (reporter or report.reported_by) }} -
- - {% module Markdown(report.comment) %} -
- {% else %} -
- {{ _("%s did not leave a comment") % (reporter or report.reported_by) }} -
- {% end %} -
@@ -102,6 +85,53 @@ {% end %} + {# Comments #} + {% if comments %} +
+ {% for comment in comments %} + {% set account = backend.accounts.get_by_uid(comment.created_by) %} + +
+ {# Avatar #} +
+ {% if account %} + +

+ {{ account }} +

+
+ {% else %} + + {% end %} +
+ + {# Comment #} +
+
+

+ + {% if account %} + {{ account }} + {% else %} + {{ _("- Unknown User -") }} + {% end %} + +

+ + {% module Markdown(comment.comment) %} + +

+ + {{ locale.format_date(comment.created_at, shorter=True) }} + +

+
+
+
+ {% end %} +
+ {% end %} + {# Actions #} {% if not report.is_closed() %} {% if current_user and current_user.is_dbl_moderator() %} diff --git a/src/web/dbl.py b/src/web/dbl.py index fea1f284..99d60797 100644 --- a/src/web/dbl.py +++ b/src/web/dbl.py @@ -129,6 +129,9 @@ class ReportHandler(base.AnalyticsMixin, BaseHandler): # Fetch the list list = await report.get_list() + # Fetch all comments + comments = await report.get_comments() + # Fetch the reporter reporter = self.backend.accounts.get_by_uid(report.reported_by) @@ -138,7 +141,7 @@ class ReportHandler(base.AnalyticsMixin, BaseHandler): else: status = await self.backend.dbl.search(report.name) - self.render("dbl/reports/show.html", report=report, + self.render("dbl/reports/show.html", report=report, comments=comments, list=list, reporter=reporter, status=status)