From nobody Fri Oct 25 19:22:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152447134479966.76311818396528; Mon, 23 Apr 2018 01:15:44 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 83C6031316E4; Mon, 23 Apr 2018 08:15:43 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 733AF77DA9; Mon, 23 Apr 2018 08:15:43 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0634F180215F; Mon, 23 Apr 2018 08:15:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3N8FH0I012929 for ; Mon, 23 Apr 2018 04:15:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0F0B86E706; Mon, 23 Apr 2018 08:15:17 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F127574929 for ; Mon, 23 Apr 2018 08:14:50 +0000 (UTC) Received: from mail-wr0-f177.google.com (mail-wr0-f177.google.com [209.85.128.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B9E3480F93 for ; Mon, 23 Apr 2018 08:14:17 +0000 (UTC) Received: by mail-wr0-f177.google.com with SMTP id g21-v6so11113653wrb.8 for ; Mon, 23 Apr 2018 01:14:17 -0700 (PDT) Received: from donizetti.lan (dynamic-adsl-78-12-189-60.clienti.tiscali.it. [78.12.189.60]) by smtp.gmail.com with ESMTPSA id x17sm6468901edx.53.2018.04.23.01.14.15 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Apr 2018 01:14:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=sHGqoEs08cx9J1Ognd7jmTMUzEI7RejrcC3S3aXLCEw=; b=T7rGPXZw8awfGaolkODB/VENpiLUVn6YlnNSxSk7KClkzZxa/9a7sA9QVVfTOXGvbg SJBxsyw92jKkYk+5c9Js5B202UOJ1R7TYwMNsXacuOYh7WZ+PuasMc++g6FtCEfmLq9c Wtne7iXARwt+Um1cBJRfSf7qIHAavXmV0swKjKoT3nukPcCjvJHZT6moAWtXuSbdWzet SqFkmEEMo2l8lOv3gQ/ISWDvwxnrZ2+YL5DZOy3Wr5ZaUyOfPaJGrURDzmlUkq19eowk ewwceboXkUoRPtuWoyD0ki7reY8JTW/f2L0nf7pROQFkUJkpOsdlwbz87zcEirlQ2ESx bZpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=sHGqoEs08cx9J1Ognd7jmTMUzEI7RejrcC3S3aXLCEw=; b=YnV8aZC206TVnImMSxZLKvmzft3izlJace0Mlihn0rPAzsx9V/Qpysocd892XX+1+g 0Z0sRAIDI4Iqtc9jCL7yXdGmMtcpZDb4UnwGiKH1/sPm6gtSpK2ZzAMN2yLeQiAG0a9f RaLxCX2Bd5QsJaQRxxZ5cD01nf53K6DpPhgXbXpu3cb6DGRDDd0RfPg5+3uef5DpFVRV c/Ja/8mKhNmSETU0lWaZq2TBmL1XqhCqP9cmnuLFIBhHGdkfIc9zIueqwiFEHPHvFLLX qb3Y62QMwDqAbyUCrThRcnyiiOjeYLemRe+RMU9a1PeOkN0MOas0Azlnb4S1hBbml+Fd PLyw== X-Gm-Message-State: ALQs6tDpO0fiH4bCjCr/nqI8gVOH3UZrF1j9342G843R/gjVfJtkIr4a dZMBs/T/1Y5ZozdMxYQnfiXNQx/h X-Google-Smtp-Source: AIpwx4//Y2QPF7BE6vo2Kel6AClXHnIepmmWFpnHuKm6ZrOmCSTplak21GwSBxAL1SfmWCkbJCGFug== X-Received: by 10.80.128.5 with SMTP id 5mr27530212eda.130.1524471256074; Mon, 23 Apr 2018 01:14:16 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Mon, 23 Apr 2018 10:14:12 +0200 Message-Id: <20180423081415.15099-2-pbonzini@redhat.com> In-Reply-To: <20180423081415.15099-1-pbonzini@redhat.com> References: <20180423081415.15099-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 23 Apr 2018 08:14:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 23 Apr 2018 08:14:18 +0000 (UTC) for IP:'209.85.128.177' DOMAIN:'mail-wr0-f177.google.com' HELO:'mail-wr0-f177.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.35 (DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.128.177 mail-wr0-f177.google.com 209.85.128.177 mail-wr0-f177.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 1/4] add result renderer infrastructure X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 23 Apr 2018 08:15:43 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Plugins can prepare the "status" section of the series/message detail pages from the same Result objects used by the REST API. Record in the Result the object that created it, so that it can prepare an HTML rendering of the Result. Signed-off-by: Paolo Bonzini --- api/models.py | 11 ++++++++--- static/css/base.css | 6 ++++-- www/templates/project-detail.html | 9 +++++++++ www/templates/series-detail.html | 9 +++++++++ www/views.py | 18 ++++++++++++++++++ 5 files changed, 48 insertions(+), 5 deletions(-) diff --git a/api/models.py b/api/models.py index 9aa1196..501070c 100644 --- a/api/models.py +++ b/api/models.py @@ -601,13 +601,18 @@ class Module(models.Model): def __str__(self): return self.name =20 -class Result(namedtuple("Result", "name status log log_url obj data")): +class Result(namedtuple("Result", "name status log log_url obj data render= er")): __slots__ =3D () =20 - def __new__(cls, name, status, obj, log=3DNone, log_url=3DNone, data= =3DNone, request=3DNone): + def __new__(cls, name, status, obj, log=3DNone, log_url=3DNone, data= =3DNone, request=3DNone, renderer=3DNone): if log_url is not None and request is not None: log_url =3D request.build_absolute_uri(log_url) if status not in ('pending', 'success', 'failure'): raise ValueError("invalid value '%s' for status field" % statu= s) return super(cls, Result).__new__(cls, status=3Dstatus, log=3Dlog,= log_url=3Dlog_url, - obj=3Dobj, data=3Ddata, name=3Dn= ame) + obj=3Dobj, data=3Ddata, name=3Dn= ame, renderer=3Drenderer) + + def render(self): + if self.renderer is None: + return None + return self.renderer.render_result(self) diff --git a/static/css/base.css b/static/css/base.css index 82995f5..35fba6e 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -137,10 +137,12 @@ h1, h2, h3, .h1, .h2, .h3 { .status-content > .fa { color: #337ab7; } -.status-content.status-alert > .fa { +.status-content.status-alert > .fa, +.status-content.status-failure > .fa { color: #CC0000; } -.status-content.status-good > .fa { +.status-content.status-good > .fa, +.status-content.status-success > .fa { color: #009900; } .status-content > div { diff --git a/www/templates/project-detail.html b/www/templates/project-deta= il.html index 80fce3b..aaccdc0 100644 --- a/www/templates/project-detail.html +++ b/www/templates/project-detail.html @@ -41,6 +41,15 @@ {% endif %} +{% for result in results %} +
+ {% if result.status =3D=3D "pending" %} + {% elif result.status =3D=3D "running" %} + {% elif result.status =3D=3D "failure" %} + {% elif result.status =3D=3D "success" %} {% endif %} +
{{ result.html }}
+
+{% endfor %} {% for status in project.extra_status %}
{% if status.icon %} diff --git a/www/templates/series-detail.html b/www/templates/series-detail= .html index 434bc35..9b2db1c 100644 --- a/www/templates/series-detail.html +++ b/www/templates/series-detail.html @@ -56,6 +56,15 @@
Only {{ series.num_patches }} patches received!
{% endif %} +{% for result in results %} +
+ {% if result.status =3D=3D "pending" %} + {% elif result.status =3D=3D "running" %} + {% elif result.status =3D=3D "failure" %} + {% elif result.status =3D=3D "success" %} {% endif %} +
{{ result.html }}
+
+{% endfor %} {% for status in series.extra_status %}
{% if status.icon %} diff --git a/www/views.py b/www/views.py index 8965ebf..b0ccf48 100644 --- a/www/views.py +++ b/www/views.py @@ -91,6 +91,21 @@ def prepare_series(request, s, skip_patches=3DFalse): add_msg_recurse(s, skip_patches) return r =20 +def prepare_results(request, obj): + results =3D [] + dispatch_module_hook("rest_results_hook", request=3Drequest, + obj=3Dobj, results=3Dresults, detailed=3DFalse) + + results_dicts =3D [] + for result in results: + html =3D result.render() + if html is None: + continue + d =3D result._asdict() + d['html'] =3D html + results_dicts.append(d) + return results_dicts + def prepare_series_list(request, sl): return [prepare_message(request, s, False) for s in sl] =20 @@ -204,6 +219,7 @@ def view_project_detail(request, project): po.extra_ops =3D [] dispatch_module_hook("prepare_project_hook", request=3Drequest, projec= t=3Dpo) return render_page(request, "project-detail.html", + results=3Dprepare_results(request, po), project=3Dpo, navigate_links=3Dnav_path, search=3D"") @@ -255,6 +271,7 @@ def view_series_detail(request, project, message_id): project=3Dproject, navigate_links=3Dnav_path, search=3Dsearch, + results=3Dprepare_results(request, s), patches=3Dprepare_patches(request, s), messages=3Dprepare_series(request, s, is_cover_lett= er)) =20 @@ -280,5 +297,6 @@ def view_series_message(request, project, thread_id, me= ssage_id): project=3Dproject, navigate_links=3Dnav_path, search=3Dsearch, + results=3D[], patches=3Dprepare_patches(request, s), messages=3Dprepare_series(request, m)) --=20 2.17.0 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel