return False
- # Comment
- comment : str = ""
-
# Block?
block : bool = True
"/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):
"""
{% 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() %}
# 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)
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)