From nobody Wed May 14 16:05:04 2025 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 1534581598312367.3241788904022; Sat, 18 Aug 2018 01:39:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 071A281DF0; Sat, 18 Aug 2018 08:39:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E9DE416C04; Sat, 18 Aug 2018 08:39:56 +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 D9ED34BB78; Sat, 18 Aug 2018 08:39:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7I8dtEm013228 for ; Sat, 18 Aug 2018 04:39:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 91BD05F7C2; Sat, 18 Aug 2018 08:39:55 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8656117F32 for ; Sat, 18 Aug 2018 08:39:52 +0000 (UTC) Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) (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 5921B3082A2C for ; Sat, 18 Aug 2018 08:39:51 +0000 (UTC) Received: by mail-wm0-f47.google.com with SMTP id t25-v6so9271804wmi.3 for ; Sat, 18 Aug 2018 01:39:51 -0700 (PDT) Received: from donizetti.lan (dynamic-adsl-78-12-184-244.clienti.tiscali.it. [78.12.184.244]) by smtp.gmail.com with ESMTPSA id j39-v6sm4830677wre.44.2018.08.18.01.39.48 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 18 Aug 2018 01:39:49 -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=F9Jspp9RQAdHQY2naC4FkTtsTGkxPnroNycr9wGTC20=; b=LwNwpq+ska7n+mn3ZZwrQFRVv5YN2zfrnmScG1wi3Z+61p5UEJnr7laCz9m5yiZjZI +Jl31CC7bOUeIxR+9Q2OANoDt+RANwlzpTmFbURT/t2h2KQYGN6AmUxlf7B2nnBqiFPg DhgRHhOvUaqjCPB6SOCc1GzOdIOLdByVpWFykze5LBoTMK8LHfqYVlSJ0ihaBhG8L6KW eY/ZVZXWa9LGr9ldq7SzPO3cCxLNy2vzFT1QEaTBiEkTrB0ZvRbYFEXLtNSwSgw2nMgW D23eee7HnKClh4PJ8E1NMNSQmCh5C2sr0C/3d3K96JK466jB0OMCJunbSxSc7WLTY0E7 1khA== 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=F9Jspp9RQAdHQY2naC4FkTtsTGkxPnroNycr9wGTC20=; b=lt2lhOu5CPvgHjRIj6M/H2d/xkpTi9Ud22GXY4yb3JfqsuOVL5r9MlD8iV5nEBe6fu m6gfFR7pI7Kp+zorZtdsIw0T4RWsN4taPMYVqrojzBAAiWeEvEPH0PiiSXeiwBBOpxU6 X6WhpHv04Loh8yFlihOoMw7nIRLI4/zvqBBM+56g37L9hwlvBh6gNIixx1114FRUTwx/ CAQR5BNMkNvW2EhhOVNFZn3bmGn3GcI5mJZ6Br1J264nA/TOzxkbdsDKZlVxEKakOA0Z 888/pbjRLN6H9SIJ00qirpOa1S885JXMxxrq7BgI0j+CG/zxHtfTmuNxh3fM3OqddEaE Ya1Q== X-Gm-Message-State: AOUpUlFPy4nlLeM5o8Pa8BMgL0YT0UkHpx4JNuEAXMf/2eqQ31ogZ/nu u/e0GXM14wY39SzMwyLNK+grVSgr X-Google-Smtp-Source: AA+uWPx3M3vsg63kKH+MexMiGV+tBzXh6vfF6J6eklQ9PhYD3srxj2GfZO3BuspmiJF9v+e4qaTvNw== X-Received: by 2002:a1c:1943:: with SMTP id 64-v6mr19958095wmz.89.1534581589793; Sat, 18 Aug 2018 01:39:49 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Sat, 18 Aug 2018 10:39:39 +0200 Message-Id: <20180818083944.19692-5-pbonzini@redhat.com> In-Reply-To: <20180818083944.19692-1-pbonzini@redhat.com> References: <20180818083944.19692-1-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Sat, 18 Aug 2018 08:39:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Sat, 18 Aug 2018 08:39:51 +0000 (UTC) for IP:'74.125.82.47' DOMAIN:'mail-wm0-f47.google.com' HELO:'mail-wm0-f47.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.008 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS) 74.125.82.47 mail-wm0-f47.google.com 74.125.82.47 mail-wm0-f47.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 4/9] git: remove prepare_series_hook, include result URI in applier-get reply 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sat, 18 Aug 2018 08:39:57 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_0 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" api.views.prepare_series is only used in two places, the search and applier-get endpoints. Simplify a bit the code by dropping support for the git properties in the search endpoint, and add a result URI that can be used for patchew-cli's applier mode to switch to the REST API. Signed-off-by: Paolo Bonzini --- api/rest.py | 2 +- api/views.py | 4 ---- mods/git.py | 30 +++++++++++++++++------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/api/rest.py b/api/rest.py index bd46211..646d6ad 100644 --- a/api/rest.py +++ b/api/rest.py @@ -102,7 +102,7 @@ def reverse_detail(obj, request): request=3Drequest, kwargs=3D{"projects_pk": m.p= roject.id, "series_message_id":= m.message_id, - "name": obj.name}), + "name": obj.name}) raise Error("unhandled object type") =20 # pluggable field for plugin support diff --git a/api/views.py b/api/views.py index 7a37481..f2262b6 100644 --- a/api/views.py +++ b/api/views.py @@ -168,8 +168,6 @@ def prepare_series(request, s, fields=3DNone): r["subject"] =3D s.subject if want_field("project"): r["project"] =3D s.project.name - if want_field("project.git"): - r["project.git"] =3D s.project.git if want_field("message-id"): r["message-id"] =3D s.message_id if want_field("patches"): @@ -178,8 +176,6 @@ def prepare_series(request, s, fields=3DNone): r["properties"] =3D s.get_properties() if want_field("is_complete"): r["is_complete"] =3D s.is_complete - dispatch_module_hook("prepare_series_hook", request=3Drequest, series= =3Ds, - response=3Dr) if fields: r =3D dict([(k, v) for k, v in r.items() if k in fields]) return r diff --git a/mods/git.py b/mods/git.py index 924547a..97db081 100644 --- a/mods/git.py +++ b/mods/git.py @@ -19,7 +19,7 @@ from django.utils.html import format_html from mod import PatchewModule from event import declare_event, register_handler, emit_event from api.models import Message, MessageProperty, Project, Result -from api.rest import PluginMethodField +from api.rest import PluginMethodField, reverse_detail from api.views import APILoginRequiredView, prepare_series from patchew.logviewer import LogView from schema import * @@ -218,16 +218,6 @@ class GitModule(PatchewModule): r =3D base.git_result return r if r and r.data.get("repo") else None =20 - def prepare_series_hook(self, request, series, response): - po =3D series.project - for prop in ["git.push_to", "git.public_repo", "git.url_template"]: - if po.get_property(prop): - response[prop] =3D po.get_property(prop) - base =3D self.get_base(series) - if base: - response["git.repo"] =3D base.data["repo"] - response["git.base"] =3D base.data["tag"] - def _poll_project(self, po): repo, branch =3D self._get_project_repo_and_branch(po) cache_repo =3D self._update_cache_repo(po.name, repo, branch) @@ -263,8 +253,22 @@ class ApplierGetView(APILoginRequiredView): =20 def handle(self, request): m =3D Message.objects.filter(results__name=3D"git", results__statu= s=3D"pending").first() - if m: - return prepare_series(request, m) + if not m: + return None + + response =3D prepare_series(request, m, fields=3D["project", "mess= age-id", "patches", "properties"]) + + po =3D m.project + for prop in ["git.push_to", "git.public_repo", "git.url_template"]: + if po.get_property(prop): + response[prop] =3D po.get_property(prop) + base =3D _instance.get_base(m) + if base: + response["git.repo"] =3D base.data["repo"] + response["git.base"] =3D base.data["tag"] + response["project.git"] =3D po.git + response["result_uri"] =3D reverse_detail(m.git_result, request) + return response =20 class ApplierReportView(APILoginRequiredView): name =3D "applier-report" --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel