]> git.ipfire.org Git - ipfire.org.git/commitdiff
dbl: Refactor the reports page
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 8 Feb 2026 18:04:13 +0000 (18:04 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 8 Feb 2026 18:04:13 +0000 (18:04 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/accounts.py
src/templates/dbl/reports/show.html
src/web/dbl.py

index cc48f686abbe7d3c2555d2523a7074e80d4fdbcc..fb26612eb1ec2fb874f1a78b094f45544c199535 100644 (file)
@@ -921,6 +921,9 @@ class Account(LDAPObject):
        def is_lwl(self):
                return self.is_member_of_group("lwl-staff")
 
+       def is_dbl_moderator(self):
+               return self.is_member_of_group("dbl-moderators")
+
        def can_be_managed_by(self, account):
                """
                        Returns True if account is allowed to manage this account
index 58452da04211e6efd046941619b9817043587661..ce1f77f919fb9db561874903c46699561c4a290f 100644 (file)
 {% end block %}
 
 {% block container %}
-       <section class="hero">
+       <section class="hero is-fullheight-with-navbar">
                <div class="hero-body">
                        <div class="container">
-                               <nav class="breadcrumb" aria-label="breadcrumbs">
-                                       <ul>
-                                               <li>
-                                                       <a href="/dbl">
-                                                               {{ _("IPFire DBL") }}
-                                                       </a>
-                                               </li>
+                               <div class="columns is-centered">
+                                       <div class="column is-half">
+                                               <h4 class="title is-4">
+                                                       {{ _("Report") }}
+                                               </h4>
 
-                                               <li>
-                                                       <a href="/dbl/lists">
-                                                               {{ _("Lists") }}
-                                                       </a>
-                                               </li>
+                                               <h6 class="subtitle is-6">
+                                                       {{ _("Submitted %s") % \
+                                                               locale.format_date(report.reported_at, shorter=True) }}
+                                               </h6>
 
-                                               <li>
-                                                       <a href="/dbl/lists/{{ list.slug }}">
-                                                               {{ list.name }}
-                                                       </a>
-                                               </li>
+                                               <nav class="panel">
+                                                       <div class="panel-block is-block p-4">
+                                                               {% set args = {
+                                                                       "name" : report.name,
+                                                                       "list" : list,
+                                                               } %}
 
-                                               <li>
-                                                       <a href="/dbl/lists/{{ list.slug }}/reports">
-                                                               {{ _("Reports") }}
-                                                       </a>
-                                               </li>
+                                                               {% if report.block %}
+                                                                       <h5 class="title is-5">
+                                                                               {{ _("%(name)s should be BLOCKED on %(list)s") % args }}
+                                                                       </h5>
+                                                               {% else %}
+                                                                       <h5 class="title is-5">
+                                                                               {{ _("%(name)s should be ALLOWED on %(list)s") % args }}
+                                                                       </h5>
+                                                               {% end %}
 
-                                               <li class="is-active">
-                                                       <a href="#" aria-current="page">{{ report }}</a>
-                                               </li>
-                                       </ul>
-                               </nav>
+                                                               <div class="columns is-vcentered">
+                                                                       <div class="column is-2 is-flex is-justify-content-center">
+                                                                               <a href="/users/{{ report.reported_by }}">
+                                                                                       {% if reporter %}
+                                                                                               <figure class="image is-64x64">
+                                                                                                       <img class="is-rounded" src="{{ reporter.avatar_url(size=128) }}">
+                                                                                               </figure>
+                                                                                       {% else %}
+                                                                                               <i class="fas fa-user" aria-hidden="true"></i>
+                                                                                       {% end %}
+                                                                               </a>
+                                                                       </div>
 
-                               <div class="card">
-                                       <div class="card-content">
-                                               <div class="content">
-                                                       <p class="title is-4">
-                                                               {{ report.name }}
-                                                       </p>
+                                                                       {# 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>
 
-                                                       <p class="subtitle is-6">
-                                                               {{ _("Submitted %(when)s by %(who)s") % {
-                                                                       "when" : locale.format_date(report.reported_at),
-                                                                       "who"  : report.reported_by,
-                                                               } }}
-                                                       </p>
-
-                                                       {# Comment #}
-                                                       {% if report.comment %}
-                                                               <pre>{{ report.comment }}</pre>
-                                                       {% end %}
+                                                                                               {% 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>
 
                                                        {# Status #}
                                                        {% if status %}
-                                                               <h5 class="title is-5">
-                                                                       {{ _("Status") }}
-                                                               </h5>
+                                                               {% for l, s in sorted(status.items()) %}
+                                                                       <a class="panel-block" href="/dbl/lists/{{ l.slug }}/domains/{{ s.domain }}">
+                                                                               <span class="panel-icon">
+                                                                                       {% if s.status == "ALLOWED" %}
+                                                                                               <i class="fa-solid fa-check has-text-success" aria-hidden="true"></i>
+                                                                                       {% elif s.status == "BLOCKED" %}
+                                                                                               <i class="fa-solid fa-ban has-text-danger" aria-hidden="true"></i>
+                                                                                       {% end %}
+                                                                               </span>
 
-                                                               <ul>
-                                                                       {% for l, s in sorted(status.items()) %}
-                                                                               <li>
-                                                                                       <a href="/dbl/lists/{{ l.slug }}/domains/{{ s.domain }}">
-                                                                                               {% if s.status == "ALLOWED" %}
-                                                                                                       {{ _("%(name)s is currently allowed on %(list)s") % {
-                                                                                                               "name"    : report.name,
-                                                                                                               "list"    : l,
-                                                                                                       } }}
-                                                                                               {% elif s.status == "BLOCKED" %}
-                                                                                                       {{ _("%(name)s is currently blocked on %(list)s") % {
-                                                                                                               "name"    : report.name,
-                                                                                                               "list"    : l,
-                                                                                                       } }}
-                                                                                               {% end %}
-                                                                                       </a>
-                                                                               </li>
-                                                                       {% end %}
-                                                               </ul>
+                                                                               {% if s.status == "ALLOWED" %}
+                                                                                       {{ _("%(name)s is currently allowed on %(list)s") % {
+                                                                                               "name"    : report.name,
+                                                                                               "list"    : l,
+                                                                                       } }}
+                                                                               {% elif s.status == "BLOCKED" %}
+                                                                                       {{ _("%(name)s is currently blocked on %(list)s") % {
+                                                                                               "name"    : report.name,
+                                                                                               "list"    : l,
+                                                                                       } }}
+                                                                               {% end %}
+                                                                       </a>
+                                                               {% end %}
                                                        {% end %}
-                                               </div>
+                                               </nav>
+
+                                               {% if current_user and current_user.is_dbl_moderator() %}
+                                                       <div class="block">
+                                                               <form method="POST" action="/dbl/reports/{{ report.id }}/approve">
+                                                                       {% raw xsrf_form_html() %}
+
+                                                                       <button class="button is-success is-fullwidth">
+                                                                               {{ _("Approve") }}
+                                                                       </button>
+                                                               </form>
+                                                       </div>
+
+                                                       <div class="block">
+                                                               <form method="POST" action="/dbl/reports/{{ report.id }}/reject">
+                                                                       {% raw xsrf_form_html() %}
+
+                                                                       <button class="button is-link is-outlined is-fullwidth">
+                                                                               {{ _("Reject") }}
+                                                                       </button>
+                                                               </form>
+                                                       </div>
+                                               {% end %}
                                        </div>
                                </div>
                        </div>
index 9beec10c65480e00dee6efa888344429972adc57..ac16132a68490b307fd1f5e2edbf1378667ddca0 100644 (file)
@@ -129,13 +129,17 @@ class ReportHandler(base.AnalyticsMixin, BaseHandler):
                # Fetch the list
                list = await report.get_list()
 
+               # Fetch the reporter
+               reporter = self.backend.accounts.get_by_uid(report.reported_by)
+
                # Fetch the domain status
                if report.is_closed():
                        status = None
                else:
                        status = await self.backend.dbl.search(report.name)
 
-               self.render("dbl/reports/show.html", report=report, list=list, status=status)
+               self.render("dbl/reports/show.html", report=report,
+                       list=list, reporter=reporter, status=status)
 
 
 class SearchHandler(base.AnalyticsMixin, BaseHandler):