]> git.ipfire.org Git - ipfire.org.git/commitdiff
dbl: Fetch comments for reports
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Feb 2026 17:51:22 +0000 (17:51 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 27 Feb 2026 17:51:22 +0000 (17:51 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/dbl.py
src/templates/dbl/reports/show.html
src/web/dbl.py

index c50301cfd15b828894a64e4cea6f08c4fee09767..63e1e06ccce686742f45c1c232dff92e69f5ca44 100644 (file)
@@ -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):
        """
index 2e586f38461b772d191814501fdad72a9ab719ac..260f1b32167068728b32b1eb210a1cd82dff3a50 100644 (file)
                                                                                        {% end %}
                                                                                </a>
                                                                        </div>
-
-                                                                       {# Comment #}
-                                                                       <div class="column">
-                                                                               {% if report.comment %}
-                                                                                       <div class="content">
-                                                                                               <h6 class="title is-6 mb-1">
-                                                                                                       {{ _("%s commented:") % (reporter or report.reported_by) }}
-                                                                                               </h6>
-
-                                                                                               {% module Markdown(report.comment) %}
-                                                                                       </div>
-                                                                               {% else %}
-                                                                                       <div class="notification">
-                                                                                               {{ _("%s did not leave a comment") % (reporter or report.reported_by) }}
-                                                                                       </div>
-                                                                               {% end %}
-                                                                       </div>
                                                                </div>
                                                        </div>
 
                                                        {% end %}
                                                </nav>
 
+                                               {# Comments #}
+                                               {% if comments %}
+                                                       <div class="block">
+                                                               {% for comment in comments %}
+                                                                       {% set account = backend.accounts.get_by_uid(comment.created_by) %}
+
+                                                                       <article class="media">
+                                                                               {# Avatar #}
+                                                                               <figure class="media-left">
+                                                                                       {% if account %}
+                                                                                               <a href="/users/{{ report.reported_by }}">
+                                                                                                       <p class="image is-64x64">
+                                                                                                               <img class="is-rounded" src="{{ account.avatar_url(size=128) }}" alt="{{ account }}">
+                                                                                                       </p>
+                                                                                               </a>
+                                                                                       {% else %}
+                                                                                               <i class="fas fa-user" aria-hidden="true"></i>
+                                                                                       {% end %}
+                                                                               </figure>
+
+                                                                               {# Comment #}
+                                                                               <div class="media-content">
+                                                                                       <div class="content">
+                                                                                               <p>
+                                                                                                       <strong>
+                                                                                                               {% if account %}
+                                                                                                                       {{ account }}
+                                                                                                               {% else %}
+                                                                                                                       {{ _("- Unknown User -") }}
+                                                                                                               {% end %}
+                                                                                                       </strong>
+                                                                                               </p>
+
+                                                                                               {% module Markdown(comment.comment) %}
+
+                                                                                               <p>
+                                                                                                       <small>
+                                                                                                               {{ locale.format_date(comment.created_at, shorter=True) }}
+                                                                                                       </small>
+                                                                                               </p>
+                                                                                       </div>
+                                                                               </div>
+                                                                       </article>
+                                                               {% end %}
+                                                       </div>
+                                               {% end %}
+
                                                {# Actions #}
                                                {% if not report.is_closed() %}
                                                        {% if current_user and current_user.is_dbl_moderator() %}
index fea1f2840c4b3b9dde141afc02ccfaee094f6a21..99d60797e250fcbc72f4178bc5951f5f8f36750d 100644 (file)
@@ -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)