From nobody Sun Dec 22 09:30:25 2024 Delivered-To: importer2@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 ARC-Seal: i=1; a=rsa-sha256; t=1556795893; cv=none; d=zoho.com; s=zohoarc; b=eMKCRbTcpUpyDVAd0Q+sC3oOo08/eHmwYl23x7UlO+VReTTflfwG2oEIv+xihK5hesOMhX2xoGYyCyn7SQxo3cDYg1ZA+j3CLsxf4y5CPutzTxE0SQQRqXWLDCAnqVc7ceAPvrCP11Rgr6AkNByHREDP9SNpvW2Cd3m7bov/7B0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556795893; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=DxOZsVwUemIJ5fHMoHKSaVGLt2jzylY4r2JGwgOkhbo=; b=ev63LIXnShKoUTccPoC4zxCZbQT1f9mEcDkMLqZCj4Jt2sTJBcvAv1hQMFzOyOoNfqJel0Awd+xE9cinjPIYJjJtaMu8eCECJ9ssuBcwhsPRA1gwoEtgMkA84pdqGCiYu4RAxcUtoAVB5/epbPTT1TyfYDO0cluUk9hiAYHKW7M= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1556795893381478.82692922610977; Thu, 2 May 2019 04:18:13 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D95283099FE3; Thu, 2 May 2019 11:18:11 +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 CEDA58ADAA; Thu, 2 May 2019 11:18:11 +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 BFF6141F3D; Thu, 2 May 2019 11:18:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x42BIAt2008917 for ; Thu, 2 May 2019 07:18:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 032F15DA35; Thu, 2 May 2019 11:18:10 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F27975DA34 for ; Thu, 2 May 2019 11:18:07 +0000 (UTC) Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) (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 A01E7C058CB4 for ; Thu, 2 May 2019 11:18:06 +0000 (UTC) Received: by mail-oi1-f171.google.com with SMTP id t189so1277055oih.12 for ; Thu, 02 May 2019 04:18:06 -0700 (PDT) Received: from localhost.localdomain ([198.59.53.9]) by smtp.gmail.com with ESMTPSA id o1sm19095697otj.11.2019.05.02.04.18.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 04:18:04 -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 :mime-version:content-transfer-encoding; bh=qELwC6ud+IXgGkmmgoYHp+SpyCvRSVl/jDwKyochCyw=; b=u5qaAIFoHg/HdUHPKm4Djf8IfhsGGaJ155SUcHLTuyt8dwjVOCwp4+wiPIMBzWdfB2 +vKQOCdKm0nNmwrQ6VnTHNFpv4ziHIYmAfzBTT1sfZYvGzdrkKLBMDX1zixNycMZMhZ1 ltkobrgOcbRZrxNB/ZxXSnLnPZyVn4Ov9ELeC4A+ZePO/RfNA5oKbk7R/e9QjfDtZ23l +SLSdNCxKNCjJZVPuWZggjBbpHJyX/7KjrfVyu1xw8OyOdgoUx1tGcsL5+kFbfOpSPOH PucJXkLHvJxb/Joe2xuzhCTcXSFaIZIs7ts37LDV7J55ynhR8PNXedRajHGRdiT1YzJZ /pnw== 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:mime-version:content-transfer-encoding; bh=qELwC6ud+IXgGkmmgoYHp+SpyCvRSVl/jDwKyochCyw=; b=XSVfyF8oA09IXz432hdzkpKX3oYNq2pWZHiS+IQajSaE7WXiM2FJKUHi3N3J4AYkff MzFbf77MS4fsWjF1N1JLtduXRsZsafxvi0wGCbeR5tDG+cPNYuAqSuXPG2T/rGpl4hzf F7vyhWxkYi8QJGR8/o6F5SUT9TGpwOPHdIRIL5BL3dBfNshbswP8+Otyp9r9ykJXvYlp LreGU58CtjaxrVtvDooPCw638pwS1RPUL2zzMWUIbA3Sha99dcb1AEo2RgcdDnmDL2i5 NTlgJkKOyR5EHSdPHvRpi5B4W/ikNcPDEUPaTZIJPhVIy/sz8g+elUeMQ1oxxivFpH56 Y01Q== X-Gm-Message-State: APjAAAW8mE2fHlXB3MO+Mz3TV2uy9/TUcaNSps4kJ6HOBkt+aPwXpz+B Lv9v+4lOV3kWz1q9FB4pbDoqpiv9mKI= X-Google-Smtp-Source: APXvYqwI3/125V4BPZXcC33h1yfAKCqeWkBaxQwEzS0N8R0l+NwvYAKIxXOmRjnb04r6FSJed37iRg== X-Received: by 2002:aca:550e:: with SMTP id j14mr1958069oib.41.1556795885792; Thu, 02 May 2019 04:18:05 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 2 May 2019 05:17:48 -0600 Message-Id: <20190502111804.15843-2-pbonzini@redhat.com> In-Reply-To: <20190502111804.15843-1-pbonzini@redhat.com> References: <20190502111804.15843-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 02 May 2019 11:18:06 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 02 May 2019 11:18:06 +0000 (UTC) for IP:'209.85.167.171' DOMAIN:'mail-oi1-f171.google.com' HELO:'mail-oi1-f171.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.125 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS, T_FILL_THIS_FORM_SHORT) 209.85.167.171 mail-oi1-f171.google.com 209.85.167.171 mail-oi1-f171.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 01/17] api, patchew-cli: remove commands to directly access properties 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: , 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 02 May 2019 11:18:11 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" set-properties was completely unused; get-project-properties was not needed for the Javascript interface, only for the "project property" command. The Django admin is enough if one needs that kind of fine-grained access. --- api/views.py | 23 -------------------- patchew-cli | 61 ---------------------------------------------------- 2 files changed, 84 deletions(-) diff --git a/api/views.py b/api/views.py index 48a3587..d323ba3 100644 --- a/api/views.py +++ b/api/views.py @@ -111,16 +111,6 @@ class AddProjectView(APILoginRequiredView): p.save() =20 =20 -class GetProjectPropertiesView(APILoginRequiredView): - name =3D "get-project-properties" - - def handle(self, request, project): - po =3D Project.objects.get(name=3Dproject) - if not po.maintained_by(request.user): - raise PermissionDenied("Access denied to this project") - return po.get_properties() - - class UpdateProjectHeadView(APILoginRequiredView): name =3D "update-project-head" allowed_groups =3D ["importers"] @@ -135,19 +125,6 @@ class UpdateProjectHeadView(APILoginRequiredView): return ret =20 =20 -class SetPropertyView(APILoginRequiredView): - name =3D "set-properties" - allowed_groups =3D ["importers"] - - def handle(self, request, project, message_id, properties): - mo =3D Message.objects.filter(project__name=3Dproject, - message_id=3Dmessage_id).first() - if not mo: - raise Http404("Message not found") - for k, v in properties.items(): - mo.set_property(k, v) - - class SetProjectPropertiesView(APILoginRequiredView): name =3D "set-project-properties" allowed_groups =3D ["maintainers"] diff --git a/patchew-cli b/patchew-cli index 7fa7d49..efc6f13 100755 --- a/patchew-cli +++ b/patchew-cli @@ -346,42 +346,10 @@ class ProjectCommand(SubCommand): finally: shutil.rmtree(wd) =20 - def project_property(self, argv): - parser =3D argparse.ArgumentParser() - parser.add_argument("name", help=3D"Name of the project") - parser.add_argument("prop", nargs=3D"?", help=3D"Name of the prope= rty") - parser.add_argument("--delete", "-d", action=3D"store_true", - help=3D"""delete the property with the given n= ame. - Must give a property name""") - parser.add_argument("value", nargs=3D"?", help=3D"Value of the pro= perty to set") - args =3D parser.parse_args(argv) - if not args.value and not args.delete: - # Get property and print them or the specified one - r =3D self.api_do("get-project-properties", - project=3Dargs.name) - if not args.prop: - for k, v in iter(r.items()) if r else []: - print(k, v) - else: - if r and args.prop in r: - print(args.prop, r[args.prop]) - else: - print("Property Not found:", args.prop) - if r and list(r.keys()): - print("There are:", ", ".join(list(r.keys()))) - else: - if args.delete: - args.value =3D None - # Set property - self.api_do("set-project-properties", project=3Dargs.name, - properties=3D{args.prop: args.value}) - def do(self, args, argv): if argv: if argv[0] =3D=3D "add": return self.add_project(argv[1:]) - elif argv[0] =3D=3D "property": - return self.project_property(argv[1:]) elif argv[0] =3D=3D "info": return self.show_project(argv[1:]) elif argv[0] =3D=3D "update": @@ -420,35 +388,6 @@ class UntestCommand(SubCommand): self.api_do("untest", terms=3Dargs.term) return 0 =20 -class SetPropertyCommand(SubCommand): - name =3D "set-property" - want_argv =3D True - - def arguments(self, parser): - parser.add_argument("--project", "-p", required=3DTrue, - help=3D"Project name") - parser.add_argument("--message-id", "-m", required=3DTrue, - help=3D"Project name") - parser.add_argument("--file", action=3D"store_true", - help=3D"Read property values from given file") - parser.add_argument("--json", action=3D"store_true", - help=3D"Read property values as json") - - def do(self, args, argv): - if not argv: - return 0 - if len(argv) % 2: - print("Name and value unpaired:", argv[-1]) - props =3D dict(list(zip(argv[::2], argv[1::2]))) - if args.file: - props =3D dict([(k, open(v, "r").read()) for k, v in props.ite= ms()]) - if args.json: - props =3D dict([(k, json.loads(v)) for k, v in props.items()]) - self.api_do("set-properties", project=3Dargs.project, - message_id=3Dargs.message_id, - properties=3Dprops) - return 0 - class TesterCommand(SubCommand): name =3D "tester" want_argv =3D True --=20 2.21.0 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Sun Dec 22 09:30:25 2024 Delivered-To: importer2@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 ARC-Seal: i=1; a=rsa-sha256; t=1556795894; cv=none; d=zoho.com; s=zohoarc; b=htc2JLivrhRw6GXSeywmKt9u04Ob+skx8R4118oHPrGfs9pGHTS8Y2JJAGDzo0iFl45zu5Y/gW73JvveBzarXFebiWFiKJGGG4WznuoaDtbhMA2XmW596SNLeOd4r9SVJq9xYSVDx3DPNqsYqhzeSgc1QnQYjZLvixYCbgelly4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556795894; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=oyolDaF+q2KM/yExffTQdbQ6xHJ4kdn1AgEEJ2PprMw=; b=jaXOSwA1IcQuifBKXC+eb/WNaCzH70g1iFgDkWVB9rxwUwLoWhwCVwun0xl1TwEbJnOWM7vA7v1JCOe7OzH8msGr32kR8s0IMoN8blj0A+5ARPZe9SHwu7LN/hOGqsHlg4fD39NXuCPU1133SNCOJlmVLuBCJhModERahHJ8eig= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1556795894168347.79759825334645; Thu, 2 May 2019 04:18:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E33D789C3F; Thu, 2 May 2019 11:18:12 +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 D71555DA34; Thu, 2 May 2019 11:18:12 +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 C35CC41F3D; Thu, 2 May 2019 11:18:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x42BIAoF008922 for ; Thu, 2 May 2019 07:18:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id A1B8AA21E; Thu, 2 May 2019 11:18:10 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9D123A21B for ; Thu, 2 May 2019 11:18:08 +0000 (UTC) Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (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 97481C0568FE for ; Thu, 2 May 2019 11:18:07 +0000 (UTC) Received: by mail-ot1-f41.google.com with SMTP id n15so1703223ota.1 for ; Thu, 02 May 2019 04:18:07 -0700 (PDT) Received: from localhost.localdomain ([198.59.53.9]) by smtp.gmail.com with ESMTPSA id o1sm19095697otj.11.2019.05.02.04.18.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 04:18:06 -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 :mime-version:content-transfer-encoding; bh=E7OUZAlStmscyfnzU7qa3wk3Cy1Bv2o4MV/bZE6QElU=; b=rYagTHB0dITjSawIFwGaGYEdK4kha+UxTfpwc35ZrEWk2fye2Mv5yD+255r1pWiPKl 5a9uxJ4OTI2VJlPPG8n+ak256hAHqDIHbUDXoR00HHvH/1a5VrnJC8o4cNQct0ro2Pt4 1+Ok99Ygq5B5IV2BQ8xpqV5R3TtmgLuZhHqp2reNsx9nLTmtZySzZ1xk7BzLz/5t4kY0 Vi4ESnrmFNXzlUBEBQ6yGdp5JX0bhCSl5ZaF2zqpnb7Py5oTKxiZ4LDAC7njQ6xVyuqP 0yfySkRnxYQYUQYoGuG1zZd3cz4nRcNj8n/tYpwk2XxzHYgZSxe9zmKYsUQVCCYrJiW4 Hq6Q== 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:mime-version:content-transfer-encoding; bh=E7OUZAlStmscyfnzU7qa3wk3Cy1Bv2o4MV/bZE6QElU=; b=s/YkpuhbHc5SGCdu1gQDqH8Ar5aLILyOv4+swRq2x8NeBe6AaqIVi0fiNzokfRXIsZ g9MRAMwti4169MvkpviYvf/vm1nuRH3bD+f0a1M/sgNmBAauBiEq1/vM+2Y8PaIUwMOf nUdNiOrALbb6Vlq37hw3D3okBTVpOr24S7BtgNpbujBOm0f3upauP5rbhuahxxyB2n5+ HFy5A5sYvIPMgc+LrJ/+wNjKp44BFDLLCbznGc+xAyWYgJZWKM+ZopVLhoiBkn6Xx8VJ Jp0nJ2oRec+JbliuPvKvu55tfZv42+jPXqNTxHWrrbKO3ePkxRjFhbejZPK8Njzddgye qUsg== X-Gm-Message-State: APjAAAWnwFRazD+2cJuyjYWghU+yP7jM8+6mCPsShfx1sb92NfD7DP2d mlADR5FTE9LkP0RScud+WQjjsUAfCvU= X-Google-Smtp-Source: APXvYqwBECT4WMK5ULXhIJGQSQ6XMknFgbkycOYBe0ffQcuA/jfDcjYG4Oqqz9QF4eYus23xsjAJUQ== X-Received: by 2002:a9d:37e6:: with SMTP id x93mr1994348otb.351.1556795886848; Thu, 02 May 2019 04:18:06 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 2 May 2019 05:17:49 -0600 Message-Id: <20190502111804.15843-3-pbonzini@redhat.com> In-Reply-To: <20190502111804.15843-1-pbonzini@redhat.com> References: <20190502111804.15843-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 02 May 2019 11:18:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 02 May 2019 11:18:07 +0000 (UTC) for IP:'209.85.210.41' DOMAIN:'mail-ot1-f41.google.com' HELO:'mail-ot1-f41.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.115 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.210.41 mail-ot1-f41.google.com 209.85.210.41 mail-ot1-f41.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 02/17] git: do not return properties from applier-get 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: , 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 02 May 2019 11:18:12 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Properties that are of interest to the applier are already returned directly in the applier-get reply; the applier is only using properties to retrieve tags from old servers that do not have commit 32bddb4 ("models: convert tags from property to field", 2018-10-30). It is not needed anymore, remove it to hide properties from the API. Signed-off-by: Paolo Bonzini --- api/views.py | 14 ++++---------- patchew-cli | 4 +--- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/api/views.py b/api/views.py index d323ba3..4ac5636 100644 --- a/api/views.py +++ b/api/views.py @@ -137,14 +137,6 @@ class SetProjectPropertiesView(APILoginRequiredView): po.set_property(k, v) =20 =20 -def get_properties(m): - r =3D m.get_properties() - # for compatibility with patchew-cli's applier mode - if m.tags: - r['tags'] =3D m.tags - return r - - class DeleteProjectPropertiesByPrefixView(APILoginRequiredView): name =3D "delete-project-properties-by-prefix" allowed_groups =3D ["maintainers"] @@ -161,7 +153,8 @@ def prepare_patch(p): r =3D {"subject": p.subject, "message-id": p.message_id, "mbox": p.get_mbox(), - "properties": get_properties(p) + # For backwards compatibility with old clients + "properties": {} } return r =20 @@ -181,7 +174,8 @@ def prepare_series(request, s, fields=3DNone): if want_field("patches"): r["patches"] =3D [prepare_patch(x) for x in s.get_patches()] if want_field("properties"): - r["properties"] =3D get_properties(s) + # For backwards compatibility with old clients + r["properties"] =3D {} if want_field("tags"): r["tags"] =3D s.tags if want_field("is_complete"): diff --git a/patchew-cli b/patchew-cli index efc6f13..bfff69c 100755 --- a/patchew-cli +++ b/patchew-cli @@ -681,9 +681,7 @@ class ApplyCommand(SubCommand): subprocess.check_output(["git", "log", "-n", "1", "--format=3D%b"], cwd=3Drepo)= \ .decode('utf-8').splitlines() - # old servers do not have "tags" directly in the response - for t in set(p["properties"].get("tags", []) + p.get("tags", [= ]) + \ - s["properties"].get("tags", []) + s.get("tags", [= ])): + for t in set(p.get("tags", []) + s.get("tags", [])): if t in commit_message_lines: continue filter_cmd +=3D "echo '%s';" % t --=20 2.21.0 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Sun Dec 22 09:30:25 2024 Delivered-To: importer2@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 ARC-Seal: i=1; a=rsa-sha256; t=1556795893; cv=none; d=zoho.com; s=zohoarc; b=kW8on7JKdOaZZDVjFP90woiwjluw2pN8Q0DjF7uBkFJKDSWA/Zc2UAZxwAgIHOV/2t5UjMmtIf7PG5MLEZp6R+jXB6/nZHJZcZJB7aPbvhU2o+i1vU3p64Tg9rMilAUBzcIVjrYEyoovhd8L5/dZWwFCNSz0WrG3++Ri0nfW3s8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556795893; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=wkRu5VcOnYN3TXpCRIyeTQqxe2WqRZTzVhgdaXliMbs=; b=WNvaY58Uz/DvXbqwyC88JUhwxR5xwmJwT56ZQVEieLGEV88Cz7Ctf2t37uLFRYvuwXHavvK3r1+jAL3MbBnbMCTjReVtp9b6CHu/FJ2YAHtmUibi4lfWYJcFM+ZqS1bHsmUljR15QdK6LmKTM+0Cxol3XUeuSsjEXie3meeQg1Y= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1556795893291461.6894024133186; Thu, 2 May 2019 04:18:13 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 03DE3C05FF7E; Thu, 2 May 2019 11:18:12 +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 E8C528ADAA; Thu, 2 May 2019 11:18:11 +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 DD14318089CA; Thu, 2 May 2019 11:18:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x42BIBkE008932 for ; Thu, 2 May 2019 07:18:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6E147827A8; Thu, 2 May 2019 11:18:11 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 68CDB7EFC4 for ; Thu, 2 May 2019 11:18:09 +0000 (UTC) Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (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 8F0A2356F1 for ; Thu, 2 May 2019 11:18:08 +0000 (UTC) Received: by mail-ot1-f48.google.com with SMTP id s11so1711907otp.0 for ; Thu, 02 May 2019 04:18:08 -0700 (PDT) Received: from localhost.localdomain ([198.59.53.9]) by smtp.gmail.com with ESMTPSA id o1sm19095697otj.11.2019.05.02.04.18.06 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 04:18:07 -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 :mime-version:content-transfer-encoding; bh=cTDaVUH5atKYH9f0YtS1I4Yib8Lp3R6m6zSaEhrwcg8=; b=d9sBBa95/zQ7rx5tGfr3NbX88cuslmf+0IpLO7TmCnsUeS/yUR2X9mL/KuLcRUGt0C 6/kGYBd9feMTU2K4h+cFSXFOjxH2xXIvC3xGyAm5+eCUK5L7WThiN5jVUhJ5bG0JPD6F vRWgjObmjuSsNIu2Vd7YOt8hRv5RzTN/OBhMkZtqrXChGa0f2QAxRIRZnw6gUVRPiiFJ BHrxTHORSPpKEqiUiR9fIdM4Lvcj1iUMBlzJAQoeDNZB3NcLEZ5Uh2Q88OUkpjL7Uq5J cKQYfVlI0HxBy3Dr3+uN34UU0RJbI7YrZiG/DT4wmpdHeMKHVxZffHsw7TU1w/H/QG6M FuXg== 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:mime-version:content-transfer-encoding; bh=cTDaVUH5atKYH9f0YtS1I4Yib8Lp3R6m6zSaEhrwcg8=; b=jyR9w582RrEDcHEGqGt4A2i/y6yuOZblcsC5mbp4KExfUG13vDwzxbgLmhHX5zSqRx rSbfLYQu5Uyfie2aiQCdW0tUgIz6aI3iIHtPvN7nmm6naJ71ftIsKUc/b+oMhRfDDtMJ D7k1xZi5prLz1S92BK52LiG/ec+uaetpJsxDl1aIw0Eoi5zGu8uaErvdXlTdiGBnJljx mDD13l0JJeqRZvHvExVHSJIDGx6zAk7PpTP10yplf2/4oD7IyezylSUPUYSzQzrY65hn wHP6/zldW0fJ8ihOjsA26FXK65GlwiUv6+EH9XgAAc/m6yDgzNLJTDVeSUBzUCFZKWdu hcaw== X-Gm-Message-State: APjAAAViRymZufmufQplzN9NeDH2G+CC76+2rWrcNAtrtbfGks3SCZTw O4xgHOXOXEgMgq4/oln3/fkcy35tgbA= X-Google-Smtp-Source: APXvYqwKSMPIeMZvtWOOJ2dXi1mgfAb6yyl2STl1K1kZD8IfKBvVmIsgJ9IHCklQM+YyrxIpIgxeuA== X-Received: by 2002:a05:6830:14c2:: with SMTP id t2mr2017372otq.64.1556795887601; Thu, 02 May 2019 04:18:07 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 2 May 2019 05:17:50 -0600 Message-Id: <20190502111804.15843-4-pbonzini@redhat.com> In-Reply-To: <20190502111804.15843-1-pbonzini@redhat.com> References: <20190502111804.15843-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 02 May 2019 11:18:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 02 May 2019 11:18:08 +0000 (UTC) for IP:'209.85.210.48' DOMAIN:'mail-ot1-f48.google.com' HELO:'mail-ot1-f48.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.126 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.210.48 mail-ot1-f48.google.com 209.85.210.48 mail-ot1-f48.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 03/17] api: do not blindly return all properties from get-projects 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: , 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 02 May 2019 11:18:12 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Only return the two properties that patchew-cli actually needs, through a new hook. Do this before the configuration is moved out of the properties table, because these "properties" are actually configuration items. This will be cleaned up once patchew-cli switches to the REST API. Signed-off-by: Paolo Bonzini --- api/views.py | 6 +++++- mods/git.py | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/api/views.py b/api/views.py index 4ac5636..887f9ed 100644 --- a/api/views.py +++ b/api/views.py @@ -18,6 +18,7 @@ import json from .search import SearchEngine from django.views.decorators.csrf import csrf_exempt from django.utils.decorators import method_decorator +from mod import dispatch_module_hook =20 =20 class APIView(View): @@ -83,8 +84,11 @@ def prepare_project(p): "url": p.url, "git": p.git, "description": p.description, - "properties": p.get_properties(), + "properties": {}, } + dispatch_module_hook("get_projects_prepare_hook", project=3Dp, + response=3Dret['properties']) + return ret =20 =20 diff --git a/mods/git.py b/mods/git.py index d0b1f87..89e711d 100644 --- a/mods/git.py +++ b/mods/git.py @@ -128,6 +128,10 @@ class GitModule(PatchewModule): def rest_series_fields_hook(self, request, fields, detailed): fields['based_on'] =3D PluginMethodField(obj=3Dself, required=3DFa= lse) =20 + def get_projects_prepare_hook(self, project, response): + response["git.head"] =3D project.get_property("git.head") + response["git.push_to"] =3D project.get_property("git.push_to") + def prepare_message_hook(self, request, message, detailed): if not message.is_series_head: return --=20 2.21.0 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Sun Dec 22 09:30:25 2024 Delivered-To: importer2@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 ARC-Seal: i=1; a=rsa-sha256; t=1556795896; cv=none; d=zoho.com; s=zohoarc; b=gW/XLNBYfQiFoAd/AhGlszHfNuGD2gW052z0BApG/3d4aIZtSzNETUKD3rtnV/XxauWDHV4mNXGORdhR5yAxZDkrpScjHePqo6+V7hfNOuyS+xwZ3iO+iuguWmXnYFZi3GnNJU5ckxlQ1v/dI4xbjc+IZlhIsRwI/3N0Ras0Dzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556795896; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=cMTEsu4jNeiBsybIeBXcULek7a6PecYwU1H27x9q9uM=; b=kPwn0VU0FxDxn5CO1fyb4VsdIH/lcj1dnxvAZ2qKgnLuLZ5YvyqTsdG9qyTCIOIYfaGiG5/Pq2UDuXYZAP/VxGoX+6DrkBlB6YiijtNOAo7u0fFXGVLodhdEkkhA0mDCyU4PpNRsAPUoqsRY+AjLe849dPVUXivOaIqtdrxg/8k= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1556795896595308.6527092447442; Thu, 2 May 2019 04:18:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 57A71307E042; Thu, 2 May 2019 11:18:15 +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 4C07F39C1; Thu, 2 May 2019 11:18:15 +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 3BE1918089CA; Thu, 2 May 2019 11:18:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x42BIE4Z008948 for ; Thu, 2 May 2019 07:18:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 237D17C5ED; Thu, 2 May 2019 11:18:14 +0000 (UTC) Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1C49C7EE6D for ; Thu, 2 May 2019 11:18:10 +0000 (UTC) Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) (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 724123082E69 for ; Thu, 2 May 2019 11:18:09 +0000 (UTC) Received: by mail-oi1-f171.google.com with SMTP id w197so1383967oia.2 for ; Thu, 02 May 2019 04:18:09 -0700 (PDT) Received: from localhost.localdomain ([198.59.53.9]) by smtp.gmail.com with ESMTPSA id o1sm19095697otj.11.2019.05.02.04.18.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 04:18:07 -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 :mime-version:content-transfer-encoding; bh=njEE+YPM8Qn9x+jLK7T+BHDMP1sVEn8Pc2FHfegwAIU=; b=IDitTWtsfb43xJAU6OHNxsV6ichioKZN83fuNT0rG2B94kn4MZ94ijlRN3wz3Kj/8p hWo7QkkMz0Twcin15FODstzquLUY31ZIcfvI5bWiIK1YJvhpgbixiYLzQru6jXXzuZSb ySwpiK3jiOwQBT4rxoU97S/KCxsII8bnBMhGXZIq1+15Y2EcQd1Jp2lR0tQRMhOgKGya Gvi+R8oZa/SpIXDv7KNu2aBbRagqjif7o4nLedjr/M9QP85JWqN/kRj+Ee8QHic53BsH 7Nw7EViNor/RGr+be11naP0E0xIgoZiX9C/j7Ci5imzd62aBrxqBEgx50nySrrtbwbQf wWOA== 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:mime-version:content-transfer-encoding; bh=njEE+YPM8Qn9x+jLK7T+BHDMP1sVEn8Pc2FHfegwAIU=; b=BrWggeHO06J7OCUAYpgsYvEAofXMK6Z5IXkquOfIWwXHuYxhWLQ5Vvg9/ia/5FkMp8 Vftnn8Ev+KgQY/V1myhQE/a2db1klPDs1ud3BYvPSTnbibvPv1NciySaQbJB01j7f5zn f3Ejla7bpYe5Pm2uQV6iZP+SY4CPp8LtvKTN8Uq5DQkk7tbq1OM8WJXYBEC/Flyvs35b xUOWj34RhDQ5ITEsOdHY3Kvi8juFVomZzV9SoB2bgDCx8Yp8JdJMfXPK2v+OOfGOlhjo WO/WPxnUb/ADngzeNkgmMa8g4EGW8LDasSXg+ITIeZtaqrHjrpU4KToOR8rOCMxWVAvy D9tA== X-Gm-Message-State: APjAAAWI3QI3wx550J7TGotqUyFcXYl9LHpShMXXNiAVK2SvWeosGm6W AnBALNhtiZ0XvMQOtFjJ37tPHNx6gqs= X-Google-Smtp-Source: APXvYqw5cxT2MUPNmP4DPSB9YW0YHwycSlX2pzpUCOxDT01XIEJMUWHUhsyf5BS/mhqiIbJlkvQCLA== X-Received: by 2002:aca:f204:: with SMTP id q4mr1944447oih.109.1556795888606; Thu, 02 May 2019 04:18:08 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 2 May 2019 05:17:51 -0600 Message-Id: <20190502111804.15843-5-pbonzini@redhat.com> In-Reply-To: <20190502111804.15843-1-pbonzini@redhat.com> References: <20190502111804.15843-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 02 May 2019 11:18:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 02 May 2019 11:18:09 +0000 (UTC) for IP:'209.85.167.171' DOMAIN:'mail-oi1-f171.google.com' HELO:'mail-oi1-f171.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.126 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.167.171 mail-oi1-f171.google.com 209.85.167.171 mail-oi1-f171.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 04/17] mods: move epilog to a .js file 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: , 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 02 May 2019 11:18:15 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Load the config editor Javascript via -""" diff --git a/static/js/config-editor.js b/static/js/config-editor.js new file mode 100644 index 0000000..f8c9454 --- /dev/null +++ b/static/js/config-editor.js @@ -0,0 +1,127 @@ +function current_project() { + return $('h2').text(); +} + +function save_done(btn, succeeded, error) { + $(btn).text("Save"); + $(btn).removeClass("disabled"); + info =3D $("
"); + if (succeeded) { + info.addClass("alert-success"); + info.html("Saved"); + } else { + info.addClass("alert-danger"); + info.html("Error: " + error); + } + info.insertBefore($(btn)); +} + +function collect_properties(btn, check_required) { + prefix =3D $(btn).parent().parent().find("#property-prefix").val(); + properties =3D {}; + $(btn).parent().parent().find(".project-property").each(function () { + if (check_required && this.required && !this.value) { + alert($(this).parent().find("label").html() + " is required!"); + $(this).focus(); + properties =3D false; + return false; + } + if (this.type =3D=3D "number") { + val =3D parseInt(this.value); + if (isNaN(val)) { + alert("Invalid number for " + this.name); + $(this).focus(); + properties =3D false; + return false; + } + } else if (this.type =3D=3D "checkbox") { + if (this.checked) { + val =3D true; + } else { + val =3D false; + } + } else { + val =3D this.value; + } + properties[prefix + this.name] =3D val; + }); + return properties; +} + +function properties_save(btn) { + if ($(btn).hasClass("disabled")) { + return; + } + props =3D collect_properties(btn, true); + if (!props) { + return; + } + $(btn).addClass("disabled"); + $(btn).text("Saving..."); + $(btn).parent().find(".save-message").remove(); + patchew_api_do("set-project-properties", + { project: current_project(), + properties: props }) + .done(function (data) { + save_done(btn, true); + }) + .fail(function (data, text, error) { + save_done(btn, false, error); + }); +} + +function collect_items(btn) { + $(btn).parent().parent().find(".map-item"); + return {}; +} + +function map_add_item(btn) { + name =3D window.prompt("Please input a name"); + if (!name || name =3D=3D 'null') { + return; + } + if (name in collect_items(btn)) { + alert(test_name + " already exists."); + return; + } + if (name.indexOf(".") >=3D 0) { + alert("Invalid name, no dot is allowed."); + return; + } + container =3D $(btn).parent().parent(); + tmpl =3D container.find("#item-template").html(); + nt =3D $(tmpl) + nt.find("#item-name").html(name); + old =3D nt.find("#property-prefix").val(); + nt.find("#property-prefix").val(old + name + "."); + container.find(".items").append(nt); +} +function map_delete_item(btn) { + name =3D $(btn).parent().parent().parent().find("#item-name").html(); + prefix =3D $(btn).parent().parent().parent().find("#prefix").val(); + if (!window.confirm("Really delete '" + name +"'?")) { + return; + } + $(btn).addClass("disabled"); + $(btn).text("Deleting..."); + $(btn).parent().find(".delete-message").remove(); + patchew_api_do("delete-project-properties-by-prefix", + { project: current_project(), + prefix: prefix }) + .done(function (data) { + container =3D $(btn).parent().parent().parent(); + container.remove(); + }) + .fail(function (data, text, error) { + $(btn).removeClass("disabled"); + $(btn).text("Delete"); + info =3D $("
"); + info.html("Error: " + error); + info.insertBefore($(btn)); + }); +} +function enum_change(which) { + val =3D $(which).val(); + desc =3D $(which).parent().find("#enum-desc-" + val).html(); + $(which).parent().find("#enum-desc").html(desc); +} diff --git a/www/templates/project-detail.html b/www/templates/project-deta= il.html index 35ee845..adf90a3 100644 --- a/www/templates/project-detail.html +++ b/www/templates/project-detail.html @@ -4,6 +4,7 @@ + {% endblock %} =20 {% block content %} --=20 2.21.0 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Sun Dec 22 09:30:25 2024 Delivered-To: importer2@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 ARC-Seal: i=1; a=rsa-sha256; t=1556795900; cv=none; d=zoho.com; s=zohoarc; b=n6PQ7RiSeZOxam3WWvaTmmKp+iUdTYbWcBw6JpViIUjbph0l5+GouppayMYt19d28RZKlMBoIIaZ8DOAkJ3ruUT5A9RyXUt9xBzgpoytYXUM71QDfqgDM57GViZi2wwqxPlcpa8hUZ2XyIqjBhEyqgpiwnhUOuP1jZ9aFL1Bjmw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556795900; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=tgDRw5nnf2gZERDOvv1+ZPHPPerd+OkeXdovZ15grbk=; b=cnI8N9WXVmBwqGuC0/h5/0DvoCO3FFlhBP/n0Lr33hLPB0ZQ/Y1Mv7UBien+dh6tMP50GhSUxp/3dJhoBnLdzqm2aIWkqaB2ubrPm6bUYRHOLn80J+rtsyqAuSbDPX0csIlAbf/kg58daheLsShOWXCxvKomiX0c9Qsf1AKmymE= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1556795900695829.6454915906943; Thu, 2 May 2019 04:18:20 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 731F899C1D; Thu, 2 May 2019 11:18:19 +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 67E351001E85; Thu, 2 May 2019 11:18:19 +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 5EAD13FB11; Thu, 2 May 2019 11:18:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x42BIHtg008995 for ; Thu, 2 May 2019 07:18:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9D078827A9; Thu, 2 May 2019 11:18:17 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 97D72827A8 for ; Thu, 2 May 2019 11:18:17 +0000 (UTC) Received: from mail-ot1-f68.google.com (mail-ot1-f68.google.com [209.85.210.68]) (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 43C32C00735C for ; Thu, 2 May 2019 11:18:10 +0000 (UTC) Received: by mail-ot1-f68.google.com with SMTP id s11so1711988otp.0 for ; Thu, 02 May 2019 04:18:10 -0700 (PDT) Received: from localhost.localdomain ([198.59.53.9]) by smtp.gmail.com with ESMTPSA id o1sm19095697otj.11.2019.05.02.04.18.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 04:18:08 -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 :mime-version:content-transfer-encoding; bh=DjPFPwZzGn4PTpbYkocaTXzwf3A035UsD1wjxc8kRqc=; b=OO9IjPnsIllk5ZS0ieX3lTrIKuT19NVfs/07zWnFQVqeCl/JA9IWFu/rFulrjDiwVI H3tU/W86g25btF0Pod2PRzKO02Lk8fjbQ6lS6/nMiiLsLiLYfpgkzuvvpWmLXVgkEgfM j/mUWjdvx3inX9hCxA9wnpoBF6s6lU3DFmwx4FgOKjvx/xR7kkiA/zD+eEiD/4Dfpb2E F/tFJnEYRcyV2sU5ux1roV6r+fLB1joihfZ5yAyzwvH5cXg0raZutkDk//AwbHJgIuDM sFRjUvoUEJ4mWUz4DJ/lLWYKoroLhoh7lHeiktafhHdrylb3ENq9nui1njv9EgiLb6za XiKg== 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:mime-version:content-transfer-encoding; bh=DjPFPwZzGn4PTpbYkocaTXzwf3A035UsD1wjxc8kRqc=; b=IlhLUfx28k1GDS47S8zSEZPC4G9UfniyGqm8ZWsJ/UBYa7oEAam/5So9usfRg+JtsQ DNxyeIOmUuuAdDhLmNeWjNUnT4vl6CwFmnAiUFcyGFHy/YNlDNzhwNW1zUfXYarumWLF OLYNR+LnjVCpw8UDYgx58RXsKZ5G02KpGRaMGrEajrCtF2zaz5OOZKFNYuVLyjDWhbeH CdTVk409LxczoL0W2Mhm7nDZoEwbyg3bXS0fTTHfdGNrAyVIFwxO7LhFNJ5Y2bc9hQwY wSIHfhXvT0fjO0IVrdbbY1SVNeZiXeTJ1LEup47iTwbehmF1tUR65dokhK0Xb8wnqNKU QykA== X-Gm-Message-State: APjAAAXVKVpRMPgX+7kcYi1BtuA60TQbuOvvmu2qK/QuFb6VosA6P6yt SQmVtN66uvop9Ft6CSZh2nloSO9NBSE= X-Google-Smtp-Source: APXvYqyImCkMzbpX60OI8kdeQowDGfzwemfdD79hLx8cwv9t9TqxpM+vg5XLu+0r5VKniQwOwNKGnw== X-Received: by 2002:a9d:5c03:: with SMTP id o3mr1980434otk.184.1556795889421; Thu, 02 May 2019 04:18:09 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 2 May 2019 05:17:52 -0600 Message-Id: <20190502111804.15843-6-pbonzini@redhat.com> In-Reply-To: <20190502111804.15843-1-pbonzini@redhat.com> References: <20190502111804.15843-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 02 May 2019 11:18:10 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 02 May 2019 11:18:10 +0000 (UTC) for IP:'209.85.210.68' DOMAIN:'mail-ot1-f68.google.com' HELO:'mail-ot1-f68.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.117 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.210.68 mail-ot1-f68.google.com 209.85.210.68 mail-ot1-f68.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 05/17] mods: use classes instead of ids 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: , 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 02 May 2019 11:18:19 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" ids should be unique, avoid duplicating them. Signed-off-by: Paolo Bonzini --- mod.py | 12 ++++++------ static/js/config-editor.js | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/mod.py b/mod.py index 7184211..7d43715 100644 --- a/mod.py +++ b/mod.py @@ -260,7 +260,7 @@ TMPL_ENUM =3D """ {% endif %} {% endfor %} -
+
{% for opt, desc in schema.enums.items %} {% if opt =3D=3D value %} """ + TMPL_ENUM_DESC + """ @@ -268,7 +268,7 @@ TMPL_ENUM =3D """ {% endfor %}
{% for opt, desc in schema.enums.items %} -
+
""" + TMPL_ENUM_DESC + """
{% endfor %} @@ -276,7 +276,7 @@ TMPL_ENUM =3D """ """ =20 TMPL_ARRAY =3D """ - + {% for schema in members %} {{ schema }} {% endfor %} @@ -293,8 +293,8 @@ TMPL_MAP_ITEM =3D """
{{ item_schema.title }} - {{ item.name }} - + {{ item.name }} +
{{ item.html }} @@ -310,7 +310,7 @@ TMPL_MAP_ITEM =3D """ =20 TMPL_MAP =3D """
-
diff --git a/static/js/config-editor.js b/static/js/config-editor.js index f8c9454..56d0781 100644 --- a/static/js/config-editor.js +++ b/static/js/config-editor.js @@ -17,7 +17,7 @@ function save_done(btn, succeeded, error) { } =20 function collect_properties(btn, check_required) { - prefix =3D $(btn).parent().parent().find("#property-prefix").val(); + prefix =3D $(btn).parent().parent().find(".property-prefix").val(); properties =3D {}; $(btn).parent().parent().find(".project-property").each(function () { if (check_required && this.required && !this.value) { @@ -89,16 +89,16 @@ function map_add_item(btn) { return; } container =3D $(btn).parent().parent(); - tmpl =3D container.find("#item-template").html(); + tmpl =3D container.find(".item-template").html(); nt =3D $(tmpl) - nt.find("#item-name").html(name); - old =3D nt.find("#property-prefix").val(); - nt.find("#property-prefix").val(old + name + "."); + nt.find(".item-name").html(name); + old =3D nt.find(".property-prefix").val(); + nt.find(".property-prefix").val(old + name + "."); container.find(".items").append(nt); } function map_delete_item(btn) { - name =3D $(btn).parent().parent().parent().find("#item-name").html(); - prefix =3D $(btn).parent().parent().parent().find("#prefix").val(); + name =3D $(btn).parent().parent().parent().find(".item-name").html(); + prefix =3D $(btn).parent().parent().parent().find(".prefix").val(); if (!window.confirm("Really delete '" + name +"'?")) { return; } --=20 2.21.0 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Sun Dec 22 09:30:25 2024 Delivered-To: importer2@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 ARC-Seal: i=1; a=rsa-sha256; t=1556795896; cv=none; d=zoho.com; s=zohoarc; b=TsT5RZ1CsSWUwNy76lDaiWgbNtdkt8Eo5xZXm+qV2KZIbPFQAtfHor4TJerSC7HmolJxx/lWdyOUUwaIEoddwYrwXRx8fFT/sDTC+yEutdHMO+S6PMI2nU4DTI75yZSsORmE++d9hZOymQjZasBZH+6P0HXzUZA/t+eipxLDaRY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556795896; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=E3UsS+fOJLXrEMvMIl+F+cS9oOVFko6CPyHQftE0ol0=; b=ljeRKF2/tWXidqoIyCjihNqrTJlUwo8xIAZ9zoj5OfU7hhc/s9RpG009z7Mmo8cuNIvDR7+dQdHG0GA5sVE6gtFJY9HhkRU0Sfi36KfU8gYdswYx+dGqFNOTtw4lOLgr5Zr4Ewo9QMwS2rkg/2bmIh6CtwLX3SExj9dVCiOYrgs= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1556795896275289.39267815039466; Thu, 2 May 2019 04:18:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0AFB8330272; Thu, 2 May 2019 11:18:15 +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 0031A39C1; Thu, 2 May 2019 11:18:14 +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 E677918089CA; Thu, 2 May 2019 11:18:14 +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 x42BIEpO008953 for ; Thu, 2 May 2019 07:18:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 51D60174B1; Thu, 2 May 2019 11:18:14 +0000 (UTC) Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4BF4339C1 for ; Thu, 2 May 2019 11:18:11 +0000 (UTC) Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) (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 1EB0630832D1 for ; Thu, 2 May 2019 11:18:11 +0000 (UTC) Received: by mail-oi1-f180.google.com with SMTP id 143so1367221oii.4 for ; Thu, 02 May 2019 04:18:11 -0700 (PDT) Received: from localhost.localdomain ([198.59.53.9]) by smtp.gmail.com with ESMTPSA id o1sm19095697otj.11.2019.05.02.04.18.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 04:18:09 -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 :mime-version:content-transfer-encoding; bh=ZYg498xb0T2jbSOuJK/pwY+LZaRs8dyeKZFqQYfIBvI=; b=cnFOWndhKnQmN8RfO5DA5VHxJX37OgEHu2xCc4GLbUWie7vNQ0iw23Ttkd2DRK7szK +9lN2Mt9iN1V4aF+YVPazhNpAsW2QbEtZpb7n4iSbKbbgnbAl+NW58N2c3tQvSdiDb14 HVvNvQPN2P20EfrGQuxA39gC0LlHtZKgVL7370Cq6sx+S6nabWWPJOBjIjY2E3OH19Mw GIw4juDdCwxPEWLNPgWugWM5F1D0P0RnjsfqiJoNI7e38vml2T0Np5ZP1J+x1EJIudWS zr87Kr45hhsS9qW81LsfOaQEPBqzg/JA76T3KlbLfX4dgKcWBpp7noDS6CcTPQbQAvrk wmAA== 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:mime-version:content-transfer-encoding; bh=ZYg498xb0T2jbSOuJK/pwY+LZaRs8dyeKZFqQYfIBvI=; b=tPbLaL8MjCcQPoLa0Z0/lfsaULr4SEthOCWLORc5fPDxrb/oxweXUNl6J0rP2P0K3f 5jrWy7otZp6EMfCwXMweSaomHaTvlu7HXlGiEZnxlpLsu2pL3PsWD9ivyq/VNzLRgm76 c6KMj/0lVGCd3lTzAlvlVbZXJIqzgdx2f9L0NzBnVEXd2WnRHOaIoyvUPmJYUMh0aCq5 vMXripdmFyNKciBt9Tcm7iIsHyhDj6gr+HxQEGNv0nV/V0j58USJHVW+CavgnhedLAC0 WX936Y0JP6vvjlk430ns5Af0jKdRpPofJL/2okbnaC1n3uujWE3Dk+2V6A/f+RWVE27c iJxQ== X-Gm-Message-State: APjAAAXhrCbAPzTytcjMQNdajxT5rA1nhfYJFeNJUU3aBmL9YfW3w8Ta GjKxdJ2cSKqgRuzwJVjxzyoupcWD8P0= X-Google-Smtp-Source: APXvYqyiy6DXhtCr67HVDuqF7Pji8nV9ZVHC6mXVPzY3lzC3V8/ojNYyYK6Q4WCCPapbsKSd3/M98Q== X-Received: by 2002:aca:d5cc:: with SMTP id m195mr1851375oig.167.1556795890351; Thu, 02 May 2019 04:18:10 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 2 May 2019 05:17:53 -0600 Message-Id: <20190502111804.15843-7-pbonzini@redhat.com> In-Reply-To: <20190502111804.15843-1-pbonzini@redhat.com> References: <20190502111804.15843-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 02 May 2019 11:18:11 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 02 May 2019 11:18:11 +0000 (UTC) for IP:'209.85.167.180' DOMAIN:'mail-oi1-f180.google.com' HELO:'mail-oi1-f180.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.126 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.167.180 mail-oi1-f180.google.com 209.85.167.180 mail-oi1-f180.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.44 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 06/17] mods: rename project_property_schema to project_config_schema 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: , 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 02 May 2019 11:18:15 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" We would like to split properties from configurations, and place them in two separate fields of the project. As a start, do not use "property" when referring to the module schemas. The fact that configuration is stored as a property is (more or less) an implementation detail. Signed-off-by: Paolo Bonzini --- mod.py | 8 ++++---- mods/email.py | 2 +- mods/git.py | 2 +- mods/testing.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mod.py b/mod.py index 7d43715..6f172d5 100644 --- a/mod.py +++ b/mod.py @@ -21,7 +21,7 @@ class PatchewModule(object): """ Module base class """ name =3D None # The name of the module, must be unique default_config =3D "" # The default config string - project_property_schema =3D None + project_config_schema =3D None =20 def get_model(self): # ALways read from DB to accept configuration update in-flight @@ -145,9 +145,9 @@ class PatchewModule(object): assert False =20 def build_config_html(self, request, project): - assert not isinstance(self.project_property_schema, StringSchema) - assert not isinstance(self.project_property_schema, IntegerSchema) - scm =3D self.project_property_schema + assert not isinstance(self.project_config_schema, StringSchema) + assert not isinstance(self.project_config_schema, IntegerSchema) + scm =3D self.project_config_schema return self._build_one(request, project, scm.name + ".", scm) =20 _loaded_modules =3D {} diff --git a/mods/email.py b/mods/email.py index 411bc4b..14553f0 100644 --- a/mods/email.py +++ b/mods/email.py @@ -88,7 +88,7 @@ Email information is configured in "INI" style: required=3DTrue), ]) =20 - project_property_schema =3D \ + project_config_schema =3D \ ArraySchema("email", desc=3D"Configuration for email module", members=3D[ MapSchema("notifications", "Email notifications", diff --git a/mods/git.py b/mods/git.py index 89e711d..110f261 100644 --- a/mods/git.py +++ b/mods/git.py @@ -63,7 +63,7 @@ class GitModule(PatchewModule): allowed_groups =3D ('importers', ) result_data_serializer_class =3D ResultDataSerializer =20 - project_property_schema =3D \ + project_config_schema =3D \ ArraySchema("git", desc=3D"Configuration for git module", members=3D[ StringSchema("push_to", "Push remote", diff --git a/mods/testing.py b/mods/testing.py index e390e30..caafc19 100644 --- a/mods/testing.py +++ b/mods/testing.py @@ -91,7 +91,7 @@ class TestingModule(PatchewModule): required=3DTrue), ]) =20 - project_property_schema =3D \ + project_config_schema =3D \ ArraySchema("testing", desc=3D"Configuration for testing module", members=3D[ MapSchema("tests", "Tests", --=20 2.21.0 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Sun Dec 22 09:30:25 2024 Delivered-To: importer2@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 ARC-Seal: i=1; a=rsa-sha256; t=1556795902; cv=none; d=zoho.com; s=zohoarc; b=W8yp8Wcm8OKBbnWXPdXNjoXyYuvB7bDnIA813BmMjOmkaqtmAuilXeTK0xhCmh+GVYgOQBvUwfb+zxK3Z+ZlzSL4lqJa4+7NqVfSAPFZddXCHnrTCSVWZGPIiUkHvkpAlqy7D7juSmr8KJFmuUgvaKOnxqFojz6FUY9TkAw08Y4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556795902; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=wxs07UtSsZMJ5mi/Fu/k1RwbmJo6YITG76D4TKRP6DU=; b=deYlBPOzKemTToFkJB07hC82A9eGTH4AK51swziHvXpShc4yCpfyVP/OrhYZYmckotNFnthIQznBjfVUxgUO/7lOrVV0uIXvYQm0SB98y3HsZC8Qj7SfBdvi6TqMtmGkjuVspnoZn6nlJrxYjCOvXEuWExcr11ak9pNwPH+YrU4= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1556795902855414.5119187729838; Thu, 2 May 2019 04:18:22 -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 958EE307D978; Thu, 2 May 2019 11:18:21 +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 87C9BA219; Thu, 2 May 2019 11:18:21 +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 7E04318089D2; Thu, 2 May 2019 11:18:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x42BIJdV009037 for ; Thu, 2 May 2019 07:18:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id E9AE37EE8B; Thu, 2 May 2019 11:18:19 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E3C2B7EF44 for ; Thu, 2 May 2019 11:18:19 +0000 (UTC) Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (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 013D130944B6 for ; Thu, 2 May 2019 11:18:12 +0000 (UTC) Received: by mail-ot1-f45.google.com with SMTP id r20so1692313otg.4 for ; Thu, 02 May 2019 04:18:11 -0700 (PDT) Received: from localhost.localdomain ([198.59.53.9]) by smtp.gmail.com with ESMTPSA id o1sm19095697otj.11.2019.05.02.04.18.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 04:18:10 -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 :mime-version:content-transfer-encoding; bh=Hi8TV2CdaeVFCN/c5P8sTwYBHNQMocxdqLYQjugNd+4=; b=HugvaykWcn5L1WegHUiVhxN9PR0QWRGKJsWo4gv1BIST1yS5d95ssBMSPmo4CDHIfX /obHG/cx6qiIa14sq2chTASyVloXrp5LBMg6YDJe29JcOR68V2uRh+rRaF/H/UtJ4vFh AMCa43/+WN5i4pZy0e5+C126fa9fvhtpzk4EKvIHLLVRV6BS++Na9gcbNJKx+Fh3dOxV xMmmeESNJYQqyMb/tFOvaI0PhwFcYrDRVQ4izYzc5yjjlqEOVmJ5X0t/d2nVCFd7UkP3 mlY2Ksyn573vHH2rooHMlsi13nKnxWOTFT4DCD22QYDwI9HCWxWp0x/VcCEel93A1Zob CZvw== 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:mime-version:content-transfer-encoding; bh=Hi8TV2CdaeVFCN/c5P8sTwYBHNQMocxdqLYQjugNd+4=; b=JbH0aa9LxXjY4PEyEv0Z3m3BT2FJBz/XxVSdfKLiQuOaD5L/GeC2MLxOqBYFzIQZcS MZbXUc6XFwD0UlKXzjl2kwl5H78Mvw8dMbhmZB5YxYAdKbl1/PxKY10qRsen+Ow7Euj0 BHQDiD8c1AQtGs6oGGaokjdLoQuWkaMfUiuZbcfK4SvQUgOUTDpMHIGzh+JdbxVGo225 jTDjtOLz6ZkOFTPRcxvD6FMwV/kIQdjK7HaXJSQT6kImwZg8VZTQPyzK84le7KhlXrV1 QIrauPLi89/AU/YXf00fyD3+SMNUtpUNbLgkJJdVt4EitwPyFxgdXLOug3+O0T5ZzWa9 TQow== X-Gm-Message-State: APjAAAUvJz49Cuf2DIeAlCOgrqBu7PccTInc02tEfkk9tiIUny2+Jijy GRTMxrs5vpmtIp/3Fwy/sGcrqBqLf+I= X-Google-Smtp-Source: APXvYqyL3z4OtwKJCet2PEEtgTSArS5V2hvucNHBdRtvtWHUsNDowPTvfjgZosrRsXm6ccFM006o3Q== X-Received: by 2002:a9d:3c2:: with SMTP id f60mr2013071otf.36.1556795891214; Thu, 02 May 2019 04:18:11 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 2 May 2019 05:17:54 -0600 Message-Id: <20190502111804.15843-8-pbonzini@redhat.com> In-Reply-To: <20190502111804.15843-1-pbonzini@redhat.com> References: <20190502111804.15843-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 02 May 2019 11:18:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 02 May 2019 11:18:12 +0000 (UTC) for IP:'209.85.210.45' DOMAIN:'mail-ot1-f45.google.com' HELO:'mail-ot1-f45.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.145 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_MSPIKE_H2, SPF_PASS, T_FILL_THIS_FORM_SHORT) 209.85.210.45 mail-ot1-f45.google.com 209.85.210.45 mail-ot1-f45.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 07/17] mods: refactor extraction of configuration into a dictionary 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: , 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.48]); Thu, 02 May 2019 11:18:21 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Both the email and testing modules have code to extract the configuration from project properties into a dictionary. Generalize that code, using the project_config_schema to drive the conversion, and use it in the git plugin as well This matches the way configuration will be stored in the database when we move away from project properties. In fact, all this nice visitor code will disappear very soon... Signed-off-by: Paolo Bonzini --- mod.py | 37 ++++++++++++++++++++++++++++++++++++- mods/email.py | 16 ++-------------- mods/git.py | 28 ++++++++++++++++------------ mods/testing.py | 25 ++++--------------------- 4 files changed, 58 insertions(+), 48 deletions(-) diff --git a/mod.py b/mod.py index 6f172d5..9e15064 100644 --- a/mod.py +++ b/mod.py @@ -53,7 +53,7 @@ class PatchewModule(object): prefix =3D prefix + scm.name + "." def _build_map_items(): r =3D {} - for p, v in project.get_properties().items(): + for p in project.get_properties().keys(): if not p.startswith(prefix): continue name =3D p[len(prefix):] @@ -150,6 +150,41 @@ class PatchewModule(object): scm =3D self.project_config_schema return self._build_one(request, project, scm.name + ".", scm) =20 + def _get_map_scm(self, project, prop_name, scm): + prefix =3D prop_name + "." + result =3D {} + for p in project.get_properties().keys(): + if not p.startswith(prefix): + continue + name =3D p[len(prefix):] + name =3D name[:name.rfind(".")] + if name in result: + continue + assert scm.item.name =3D=3D '{name}' + value =3D self._get_one(project, prefix + name, scm.item) + result[name] =3D value + return result + + def _get_array_scm(self, project, prop_name, scm): + prefix =3D prop_name + "." + result =3D {} + for i in scm.members: + assert i.name !=3D '{name}' + result[i.name] =3D self._get_one(project, prefix + i.name, i) + return result + + def _get_one(self, project, prop_name, scm): + if type(scm) =3D=3D MapSchema: + return self._get_map_scm(project, prop_name, scm) + elif type(scm) =3D=3D ArraySchema: + return self._get_array_scm(project, prop_name, scm) + else: + return project.get_property(prop_name) + + def get_project_config(self, project): + scm =3D self.project_config_schema + return self._get_one(project, scm.name, scm) + _loaded_modules =3D {} =20 def _module_init_config(cls): diff --git a/mods/email.py b/mods/email.py index 14553f0..23590d4 100644 --- a/mods/email.py +++ b/mods/email.py @@ -52,7 +52,7 @@ Email information is configured in "INI" style: default_config =3D _default_config =20 email_schema =3D \ - ArraySchema("email_notification", "Email Notification", + ArraySchema("{name}", "Email Notification", desc=3D"Email notification", members=3D[ EnumSchema("event", "Event", @@ -191,19 +191,7 @@ Email information is configured in "INI" style: return "<%s@patchew.org>" % uuid.uuid1() =20 def get_notifications(self, project): - ret =3D {} - for k, v in project.get_properties().items(): - if not k.startswith("email.notifications."): - continue - tn =3D k[len("email.notifications."):] - if "." not in tn: - continue - an =3D tn[tn.find(".") + 1:] - tn =3D tn[:tn.find(".")] - ret.setdefault(tn, {}) - ret[tn][an] =3D v - ret[tn]["name"] =3D tn - return ret + return self.get_project_config(project).get("notifications", {}) =20 def on_event(self, event, **params): class EmailCancelled(Exception): diff --git a/mods/git.py b/mods/git.py index 110f261..d459a0b 100644 --- a/mods/git.py +++ b/mods/git.py @@ -98,9 +98,6 @@ class GitModule(PatchewModule): if series.is_complete: self.mark_as_pending_apply(series) =20 - def get_project_config(self, project, what): - return project.get_property("git." + what) - def _is_repo(self, path): if not os.path.isdir(path): return False @@ -116,10 +113,14 @@ class GitModule(PatchewModule): =20 def get_mirror(self, po, request, format): response =3D {} - for key, prop in (("head", "git.head"), - ("pushurl", "git.push_to"), - ("url", "git.public_repo")): - response[key] =3D po.get_property(prop) or None + config =3D self.get_project_config(po) + if "push_to" in config: + response["pushurl"] =3D config["push_to"] + if "public_repo" in config: + response["url"] =3D config["public_repo"] + head =3D po.get_property("git.head") + if head: + response["head"] =3D head return response =20 def rest_project_fields_hook(self, request, fields): @@ -130,7 +131,9 @@ class GitModule(PatchewModule): =20 def get_projects_prepare_hook(self, project, response): response["git.head"] =3D project.get_property("git.head") - response["git.push_to"] =3D project.get_property("git.push_to") + config =3D self.get_project_config(project) + if "push_to" in config: + response["git.push_to"] =3D config["push_to"] =20 def prepare_message_hook(self, request, message, detailed): if not message.is_series_head: @@ -264,9 +267,9 @@ class ApplierGetView(APILoginRequiredView): "properties", "tags"= ]) =20 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) + config =3D _instance.get_project_config(po) + for k, v in config.items(): + response["git." + k] =3D v base =3D _instance.get_base(m) if base: response["git.repo"] =3D base.data["repo"] @@ -296,7 +299,8 @@ class ApplierReportView(APILoginRequiredView): if url: data['url'] =3D url elif tag: - url_template =3D p.get_property("git.url_template") + config =3D _instance.get_project_config(po) + url_template =3D config.get("url_template") if url_template: data['url'] =3D url_template.replace("%t", tag) if base: diff --git a/mods/testing.py b/mods/testing.py index caafc19..0125288 100644 --- a/mods/testing.py +++ b/mods/testing.py @@ -298,18 +298,7 @@ class TestingModule(PatchewModule): ret =3D {} if isinstance(obj, Message): obj =3D obj.project - for k, v in obj.get_properties().items(): - if not k.startswith("testing.tests."): - continue - tn =3D k[len("testing.tests."):] - if "." not in tn: - continue - an =3D tn[tn.find(".") + 1:] - tn =3D tn[:tn.find(".")] - ret.setdefault(tn, {}) - ret[tn][an] =3D v - ret[tn]["name"] =3D tn - return ret + return self.get_project_config(obj).get("tests", {}) =20 def _build_reset_ops(self, obj): if isinstance(obj, Message): @@ -409,15 +398,8 @@ class TestingModule(PatchewModule): project.extra_ops +=3D self._build_reset_ops(project) =20 def get_capability_probes(self, project): - ret =3D {} - for k, v in project.get_properties().items(): - prefix =3D "testing.requirements." - if not k.startswith(prefix): - continue - name =3D k[len(prefix):] - name =3D name[:name.find(".")] - ret[name] =3D v - return ret + props =3D self.get_project_config(project).get('requirements', {}) + return {k: v['script'] for k, v in props.items()} =20 def get_testing_probes(self, project, request, format): return self.get_capability_probes(project) @@ -494,6 +476,7 @@ class TestingGetView(APILoginRequiredView): if req not in capabilities: break else: + t["name"] =3D tn yield r, t =20 def _find_project_test(self, request, po, tester, capabilities): --=20 2.21.0 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Sun Dec 22 09:30:25 2024 Delivered-To: importer2@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 ARC-Seal: i=1; a=rsa-sha256; t=1556795899; cv=none; d=zoho.com; s=zohoarc; b=Oi8NsCTmR/5sRKuAhUFduBhYv6PhJxHG+FpMAwtQpQYsI05fgvj+12MaDCskCBdeH4oziLUWvEAXdoQat+HeSGcTiEWrOtTR7ZjoUb5KQOVoQF+9RI5K4vr8gOH7E8s/JJr+fSRPdSVjVEDTGabHOaU4mJABhkm8+iuuqbw8Ueo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556795899; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=uzOfD1hbeKZJRnnD0DfZxWSCsNSQcDDQZiN9RSYTalE=; b=M6LM/Y/pPbadokZdAGVW8kENOXoo9+6J9UsDUV6Xnsbd8q2U3jx8TumV3knqLZ5mGvfI6G2yLUkTDB4W/sYlcByr1j8Nf3mD9opLAVD6U8yb3HnVd0MtcNNqAAcPyUESL9qiDjZudpYhDZR6CzldZ4DL2/oJ/dqw+InfhKbPs7U= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1556795899575172.03263977216045; Thu, 2 May 2019 04:18:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 498D937E7B; Thu, 2 May 2019 11:18:18 +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 3B1B25DA35; Thu, 2 May 2019 11:18:18 +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 2F4C841F3E; Thu, 2 May 2019 11:18:18 +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 x42BIG7C008975 for ; Thu, 2 May 2019 07:18:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2B49C8ADB1; Thu, 2 May 2019 11:18:16 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 253E38ADAE for ; Thu, 2 May 2019 11:18:13 +0000 (UTC) Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) (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 DA92237E7B for ; Thu, 2 May 2019 11:18:12 +0000 (UTC) Received: by mail-oi1-f174.google.com with SMTP id k9so1294018oig.9 for ; Thu, 02 May 2019 04:18:12 -0700 (PDT) Received: from localhost.localdomain ([198.59.53.9]) by smtp.gmail.com with ESMTPSA id o1sm19095697otj.11.2019.05.02.04.18.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 04:18:11 -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 :mime-version:content-transfer-encoding; bh=YZEz7ViYd3igJNt4Wu2wfdgIPKdkWiKaYpscTpk97oY=; b=H4H6bDimE59Q+2kBSGSXwmln1AVic6Sgk/3eFtO/shCVUtFgOO97nq1MLPMh2DJVtm /uKdfeAf9/QSguoGqMXfn7QF1thNdw6WNB7xdKFzxwbQPLWQB9iN8wOZ1z7kStAJCYLO EvSQ/LloweEpM/Dlu22SOzkbcxRTaxI+qpeBO8hpCXR6ODzwUidy7tY4eFwk+nxVZHUy MsrMUXaoTFbwMtlI51iAzkVWerZDbrYPFFc58iszuiasXqFsIuLll2IkTbVPw+FJD763 Z1Y9FJAXceBx19urKeOfpnE21ALvHccIte3NYU0Ww8AWB2zpbM5Stw8Ea6ofEhqj+X6T q0ZQ== 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:mime-version:content-transfer-encoding; bh=YZEz7ViYd3igJNt4Wu2wfdgIPKdkWiKaYpscTpk97oY=; b=R8X3qmPdSf6xXBQ9Q90ZklnmaUoLzKRXBXpDQctKSfNHg8L84UdR1EZ2Qr0FVPB5wX UT2WRwSpautlTFcoURG++we13uW3xKxthosvxVCJcn4KYqbz7mqJaZzayreP60iPkiPc PJ1IzM1PuUH/E2ZD+rvvFtY6YBQndlN7j0d+OasMNS2iM9pwNefkiM2M1VV6yQk6u4Tr 2FJa7uJaAt1x8uRyrEQROXNFnNhpU8/R3jKQCBQAWIl8nypiugqEK3ZujlA1ZH9quaIU IBbJqmHduCQ5WScsESzMc7FUaRuMltpo+hhWgTk5VRUJsJwc76F5YWKI+LlorHNSXY4g enxw== X-Gm-Message-State: APjAAAU4VNe8k4EEkMFQ3NvciXjXhukkfVIpQE+1Q6crFcxuH14/0cAf 94j9VGLD5TEweqO0Uy1hqLMYrUPHfuA= X-Google-Smtp-Source: APXvYqwShqmh536mAD7fvBWwVnSu+8+sAC3d3D9Y6rVZRTlcQ8kcii+SLl4zt1mX9GaCyBy+Lj8PJg== X-Received: by 2002:aca:4d2:: with SMTP id 201mr1935688oie.12.1556795892025; Thu, 02 May 2019 04:18:12 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 2 May 2019 05:17:55 -0600 Message-Id: <20190502111804.15843-9-pbonzini@redhat.com> In-Reply-To: <20190502111804.15843-1-pbonzini@redhat.com> References: <20190502111804.15843-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 02 May 2019 11:18:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 02 May 2019 11:18:13 +0000 (UTC) for IP:'209.85.167.174' DOMAIN:'mail-oi1-f174.google.com' HELO:'mail-oi1-f174.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.136 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS, T_FILL_THIS_FORM_SHORT) 209.85.167.174 mail-oi1-f174.google.com 209.85.167.174 mail-oi1-f174.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 08/17] mods: refactor construction of config editor HTML 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: , 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 02 May 2019 11:18:18 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Refactor the Javascript config editor to work on the properties dictionary that is retrieved by get_project_config. The _build_*_scm functions therefore no longer need to understand how properties are stored in the dat= abase. --- mod.py | 77 ++++++++++++++++++++-------------------------------------- 1 file changed, 27 insertions(+), 50 deletions(-) diff --git a/mod.py b/mod.py index 9e15064..4cf2e9f 100644 --- a/mod.py +++ b/mod.py @@ -49,29 +49,13 @@ class PatchewModule(object): data["module"] =3D self return Template(tmpl).render(Context(data)) =20 - def _build_map_scm(self, request, project, prefix, scm): - prefix =3D prefix + scm.name + "." - def _build_map_items(): - r =3D {} - for p in project.get_properties().keys(): - if not p.startswith(prefix): - continue - name =3D p[len(prefix):] - name =3D name[:name.rfind(".")] - if name in r: - continue - pref =3D prefix + name + "." - r[name] =3D { - "name": name, - "html": self._build_one(request, project, - pref, scm.item) - } - return list(r.values()) - - schema_html =3D self._build_one(request, project, prefix, - scm.item) + def _build_map_scm(self, request, project, prefix, config, scm): + schema_html =3D self._build_one(request, project, "", {}, scm.item) item =3D {"html": schema_html} - items =3D _build_map_items() + items =3D [{ + "name": name, + "html": self._build_one(request, project, prefix + "." + name, + value, scm.item)} for name, value in c= onfig.items()] return self._render_template(request, project, TMPL_MAP, schema=3Dscm, item_schema=3Dscm.item, @@ -79,9 +63,10 @@ class PatchewModule(object): items=3Ditems, item=3Ditem) =20 - def _build_array_scm(self, request, project, prefix, scm): + def _build_array_scm(self, request, project, prefix, config, scm): members =3D [self._build_one(request, project, - prefix, x) for x in scm.me= mbers] + prefix + "." + x.name, + config.get(x.name), x) for x in scm.mem= bers] show_save_button =3D False for m in scm.members: if type(m) =3D=3D StringSchema: @@ -93,62 +78,54 @@ class PatchewModule(object): show_save_button=3Dshow_save_button, prefix=3Dprefix) =20 - def _build_string_scm(self, request, project, prefix, scm): - prop_name =3D prefix + scm.name - prop_value =3D project.get_property(prop_name) + def _build_string_scm(self, request, project, prefix, config, scm): return self._render_template(request, project, TMPL_STRING, schema=3Dscm, name=3Dscm.name, prefix=3Dprefix, - value=3Dprop_value) + value=3Dconfig or '') =20 - def _build_integer_scm(self, request, project, prefix, scm): - prop_name =3D prefix + scm.name - prop_value =3D project.get_property(prop_name) + def _build_integer_scm(self, request, project, prefix, config, scm): return self._render_template(request, project, TMPL_INTEGER, schema=3Dscm, name=3Dscm.name, prefix=3Dprefix, - value=3Dprop_value) + value=3Dconfig or 0) =20 - def _build_boolean_scm(self, request, project, prefix, scm): - prop_name =3D prefix + scm.name - prop_value =3D project.get_property(prop_name) + def _build_boolean_scm(self, request, project, prefix, config, scm): return self._render_template(request, project, TMPL_BOOLEAN, schema=3Dscm, name=3Dscm.name, prefix=3Dprefix, - value=3Dprop_value) + value=3Dconfig or False) =20 - def _build_enum_scm(self, request, project, prefix, scm): - prop_name =3D prefix + scm.name - prop_value =3D project.get_property(prop_name) + def _build_enum_scm(self, request, project, prefix, config, scm): return self._render_template(request, project, TMPL_ENUM, schema=3Dscm, name=3Dscm.name, prefix=3Dprefix, - value=3Dprop_value) + value=3Dconfig) =20 - def _build_one(self, request, project, prefix, scm): + def _build_one(self, request, project, prefix, config, scm): if type(scm) =3D=3D MapSchema: - return self._build_map_scm(request, project, prefix, scm) + return self._build_map_scm(request, project, prefix, config, s= cm) elif type(scm) =3D=3D StringSchema: - return self._build_string_scm(request, project, prefix, scm) + return self._build_string_scm(request, project, prefix, config= , scm) elif type(scm) =3D=3D IntegerSchema: - return self._build_integer_scm(request, project, prefix, scm) + return self._build_integer_scm(request, project, prefix, confi= g, scm) elif type(scm) =3D=3D BooleanSchema: - return self._build_boolean_scm(request, project, prefix, scm) + return self._build_boolean_scm(request, project, prefix, confi= g, scm) elif type(scm) =3D=3D EnumSchema: - return self._build_enum_scm(request, project, prefix, scm) + return self._build_enum_scm(request, project, prefix, config, = scm) elif type(scm) =3D=3D ArraySchema: - return self._build_array_scm(request, project, prefix, scm) + return self._build_array_scm(request, project, prefix, config,= scm) assert False =20 def build_config_html(self, request, project): - assert not isinstance(self.project_config_schema, StringSchema) - assert not isinstance(self.project_config_schema, IntegerSchema) + assert isinstance(self.project_config_schema, ArraySchema) scm =3D self.project_config_schema - return self._build_one(request, project, scm.name + ".", scm) + config =3D self.get_project_config(project) + return self._build_one(request, project, scm.name, config, scm) =20 def _get_map_scm(self, project, prop_name, scm): prefix =3D prop_name + "." --=20 2.21.0 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Sun Dec 22 09:30:25 2024 Delivered-To: importer2@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 ARC-Seal: i=1; a=rsa-sha256; t=1556795905; cv=none; d=zoho.com; s=zohoarc; b=LrUWdGaK+XUW2wBPuefeanar96CM33g1W+y3EQVnOiH9qvt7AXxjKAsw/HXG8VUzhHAGZBtHRwmzIRp6ZVvn7e3tSnhOb/1qBBBVzMRcG392pd8+Q3upLwz3j/8eMZzCZqBwO6JXhBfkPioncWBAAMpy4YOKmGXgQOpyOxGtTyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556795905; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=5Jg/vbXcr8dIMm8GGNPm/U8SzYetWAQvGGjMP9G0naI=; b=Zewsq2OujCqyen8QQKjSW9PGSgpBAYL4gq4HgyT4gQgaSwJZ5lr5ObCcYAb34sMlydCkFamW/qck/M87Ahdgz6men+C7+511JISwyke4SqvJekEOM0ComBn8oDZumfNYNJUP+P5IWhAPA97jdVZ9tM71/PJluHNnKRcAtx4L43k= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1556795905936862.8681776678409; Thu, 2 May 2019 04:18:25 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE9A1302451A; Thu, 2 May 2019 11:18:24 +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 A3BDC827A8; Thu, 2 May 2019 11:18:24 +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 99EFC18089CC; Thu, 2 May 2019 11:18:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x42BIL2k009057 for ; Thu, 2 May 2019 07:18:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 54E1CA219; Thu, 2 May 2019 11:18:21 +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 4EEF1A21F for ; Thu, 2 May 2019 11:18:21 +0000 (UTC) Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (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 1D1D789C3A for ; Thu, 2 May 2019 11:18:14 +0000 (UTC) Received: by mail-ot1-f41.google.com with SMTP id r20so1692385otg.4 for ; Thu, 02 May 2019 04:18:14 -0700 (PDT) Received: from localhost.localdomain ([198.59.53.9]) by smtp.gmail.com with ESMTPSA id o1sm19095697otj.11.2019.05.02.04.18.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 04:18:12 -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 :mime-version:content-transfer-encoding; bh=36aB5P9HxJ/7MADVgpJ8Bp+y5C1TPiEUdyHkO5Ze7nc=; b=uMqhgYwmMPYfQTT2ZSXi+V7NKpNowObIJNU7cPn1KBgA6oCypPEFnirNKOA9QVQUbj vcBZcS9nuXIsiuxf4NiBOXTYlncJp1t6CksqUXXKLOVTFpajJgtK7nEHUslaJcn1X3pe zABK03WIiVi1CQ0yCm9OrjsVYOSjxoe/o9FcIg9gDde4nm5pXA+BQlULjZ+NAMquQ/02 cKevuPQACkMQ4TduuijDvknOASLHYnmfIVTFJFh08MND+jPkg7q8lWY5CbebieT0yW3b VHA9PnQNgN3awY8j6FCm251TEM9BV0o/iUGganpM9asqby2HyXjAYcu3DoGm8qmVpICL nxwA== 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:mime-version:content-transfer-encoding; bh=36aB5P9HxJ/7MADVgpJ8Bp+y5C1TPiEUdyHkO5Ze7nc=; b=PNN6ujpfZM4JeCiyoBg/Z/bmbxOEmpfoqAEmufolKfTFCZdTYfP/JSMQJbvv6VxC7W /TAyKq1yWJE72/oopXS/5EZTPK7Oc9cYksueCGBATbKNdiKoj0hrFTCwd9zN9OxDmvad ITIzriFwJ7mlSufa2XG1VZ8mK9UdB3peubwRhYyNhqcheLfxS6EGfSG18BcTA/OmEyTA u5wTAoy1dVzogBEQuy1M5ykiXcqsEMgHuAZHhpagITjU4P+nU1ANY9UPxZNESr1H/x8K /16PF2Eshqyh/yU4T96gg2JVBk9Fib+os8fZ26T9tzfohpi4D4UrFkqkgu6KRvPNl/Yy XGNw== X-Gm-Message-State: APjAAAUUmWk++bfmVbjZl35lBU9undzrmk34oi3yzw5V1YWMvjVBGepU Plf4xo1KQO9MiRNX0K0yVjK651JfJPQ= X-Google-Smtp-Source: APXvYqzCtiMKWH37lDGO9civirCKrwLZbPusWnNGrAL06LxRLiEmFpWRhEyg6zxaxH/Fan4/Rylvmw== X-Received: by 2002:a9d:ed2:: with SMTP id 76mr1981730otj.327.1556795893285; Thu, 02 May 2019 04:18:13 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 2 May 2019 05:17:56 -0600 Message-Id: <20190502111804.15843-10-pbonzini@redhat.com> In-Reply-To: <20190502111804.15843-1-pbonzini@redhat.com> References: <20190502111804.15843-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 02 May 2019 11:18:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 02 May 2019 11:18:14 +0000 (UTC) for IP:'209.85.210.41' DOMAIN:'mail-ot1-f41.google.com' HELO:'mail-ot1-f41.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.126 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.210.41 mail-ot1-f41.google.com 209.85.210.41 mail-ot1-f41.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 09/17] mods: place a single Save button at the end of the forms 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: , 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 02 May 2019 11:18:24 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Because the save button now acts on the whole config, we cannot anymore rely on finding the property prefix from the save button's parents. Instead, each property control has a data-property-path attribute and building the configuration dictionary is as simple as looking all of them up. Likewise, each map item has a data-property-prefix attribute which simplifies deletion and is also used to build the data-property-path when a new map item is added. --- mod.py | 25 +++++++------------------ static/js/config-editor.js | 30 ++++++++++++++++++------------ www/templates/project-detail.html | 7 +++++++ 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/mod.py b/mod.py index 4cf2e9f..1b7910c 100644 --- a/mod.py +++ b/mod.py @@ -67,15 +67,9 @@ class PatchewModule(object): members =3D [self._build_one(request, project, prefix + "." + x.name, config.get(x.name), x) for x in scm.mem= bers] - show_save_button =3D False - for m in scm.members: - if type(m) =3D=3D StringSchema: - show_save_button =3D True - break return self._render_template(request, project, TMPL_ARRAY, schema=3Dscm, members=3Dmembers, - show_save_button=3Dshow_save_button, prefix=3Dprefix) =20 def _build_string_scm(self, request, project, prefix, config, scm): @@ -206,6 +200,7 @@ TMPL_STRING =3D """ {% for schema in members %} {{ schema }} {% endfor %} -{% if show_save_button %} -
- -
-{% endif %} """ =20 TMPL_MAP_ITEM =3D """ -
-
+
+
{{ item_schema.title }} {{ item.name }} -
{{ item.html }} @@ -321,7 +310,7 @@ TMPL_MAP_ITEM =3D """ """ =20 TMPL_MAP =3D """ -
+
diff --git a/static/js/config-editor.js b/static/js/config-editor.js index 56d0781..f15211f 100644 --- a/static/js/config-editor.js +++ b/static/js/config-editor.js @@ -17,9 +17,9 @@ function save_done(btn, succeeded, error) { } =20 function collect_properties(btn, check_required) { - prefix =3D $(btn).parent().parent().find(".property-prefix").val(); properties =3D {}; $(btn).parent().parent().find(".project-property").each(function () { + path =3D $(this).data('property-path'); if (check_required && this.required && !this.value) { alert($(this).parent().find("label").html() + " is required!"); $(this).focus(); @@ -43,7 +43,7 @@ function collect_properties(btn, check_required) { } else { val =3D this.value; } - properties[prefix + this.name] =3D val; + properties[path] =3D val; }); return properties; } @@ -80,6 +80,7 @@ function map_add_item(btn) { if (!name || name =3D=3D 'null') { return; } + container =3D $(btn).parent().parent(); if (name in collect_items(btn)) { alert(test_name + " already exists."); return; @@ -88,17 +89,23 @@ function map_add_item(btn) { alert("Invalid name, no dot is allowed."); return; } - container =3D $(btn).parent().parent(); tmpl =3D container.find(".item-template").html(); - nt =3D $(tmpl) - nt.find(".item-name").html(name); - old =3D nt.find(".property-prefix").val(); - nt.find(".property-prefix").val(old + name + "."); - container.find(".items").append(nt); + nt =3D $(tmpl); + nt.find(".item-name").text(name); + prefix =3D nt.data('property-prefix') + '.' + name; + nt.data('property-prefix', prefix); + nt.find(".project-property").each(function() { + old =3D $(this).data('property-path'); + $(this).data('property-path', prefix + old); + }); + nt.find(".panel-collapse").collapse("show"); + container.find("> .items").append(nt); } + function map_delete_item(btn) { - name =3D $(btn).parent().parent().parent().find(".item-name").html(); - prefix =3D $(btn).parent().parent().parent().find(".prefix").val(); + item =3D $(btn).parent().parent().parent(); + name =3D item.find(".item-name").text(); + prefix =3D item.data('property-prefix') + "."; if (!window.confirm("Really delete '" + name +"'?")) { return; } @@ -109,8 +116,7 @@ function map_delete_item(btn) { { project: current_project(), prefix: prefix }) .done(function (data) { - container =3D $(btn).parent().parent().parent(); - container.remove(); + item.remove(); }) .fail(function (data, text, error) { $(btn).removeClass("disabled"); diff --git a/www/templates/project-detail.html b/www/templates/project-deta= il.html index adf90a3..5895314 100644 --- a/www/templates/project-detail.html +++ b/www/templates/project-detail.html @@ -78,6 +78,13 @@
{% endfor %} + {% if request.user.is_authenticated %} +
+ +
+ {% endif %}
=20