From nobody Fri Apr 26 18:26:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1531369315410992.7034592420663; Wed, 11 Jul 2018 21:21:55 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5232C804E3; Thu, 12 Jul 2018 04:21:54 +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 3C4895C6C2; Thu, 12 Jul 2018 04:21:54 +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 2BE1218037EC; Thu, 12 Jul 2018 04:21:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6C4Lqpa019990 for ; Thu, 12 Jul 2018 00:21:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id B4E74308BDB0; Thu, 12 Jul 2018 04:21:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AC358308BDAE for ; Thu, 12 Jul 2018 04:21:49 +0000 (UTC) Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) (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 9D955308FB9A for ; Thu, 12 Jul 2018 04:21:38 +0000 (UTC) Received: by mail-pf0-f196.google.com with SMTP id l123-v6so19774352pfl.13 for ; Wed, 11 Jul 2018 21:21:38 -0700 (PDT) Received: from localhost.localdomain ([112.196.135.182]) by smtp.gmail.com with ESMTPSA id i12-v6sm31294658pgd.87.2018.07.11.21.21.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jul 2018 21:21:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=f4Xy4+eNkIVvUAaWtgdIONCZmY+4cnbRGaw0jbNjWW0=; b=dGabnTLEbrSlQ2gWU/SvGazE0HXmS7rw3f6wiRRpljhKNg7ULgzRwxYbHnRbgnC0j5 ohDonkMAMySAjqnT2zMfG6Kg/WWI8v7Rcd0YndpBhf7un/5y5uT1svPzvykeiJaVC2J0 9UDds0FedBy6tdWCtmpU6rYjVknt5C9cUpq8cPq73UFluxTnX7vN9RG8mC5opZCVrreN UyaYwA6JcFLr8K8Sl3mGfGc8uF+MQb9Fk5SLwRB7pxXBHpsu8HowJXO5udhu41a5oyrB A1fIONEHpiXXT3pFX67T9CgwHi9Xw46LpXNHsnYQ7e/Q3lqfcI1NkTjgkmFtXjOaxZxn XTWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=f4Xy4+eNkIVvUAaWtgdIONCZmY+4cnbRGaw0jbNjWW0=; b=tOuj2PCbz+uROzwxanyTXjBOUlFcZ/apuoXSV+yfjtrvYN7MxGn/1vhttAXWOknzs4 WKLlINo/TpXF/S127Xik5wiCmZFdKnLfvV5LYKO4z1LppMWQYFVTJCyqila3U1ZWm2wl jjBfs6L6p2jdpr7sA2crA/1gwClnIFet7Oyyk0AgwB5n4Lfz5Mhe56qiX4dFaKZeQSB3 eMk6OeEVr5m8aixpiGgzdxoPxE/vdJXdSrZH/8rOfuqHeqsNP9uBBw+KrrBnkzCeNTDo 38BYHdkqREtQBovkfdJRijM4REdXtYfzq9VSjUMwmMKGKNBzCA8r0o5U56uu4fPMQ48Q wA1g== X-Gm-Message-State: AOUpUlFhHaRLYFoChoC6cOX+IpU5l+I/pImd6SuXr7EUn0zlbIO/nBNR tx9Ilai41I15Uc+yuDwhwrowoQ== X-Google-Smtp-Source: AAOMgpcFraeBX77KiIDD1qMZxPhOfxoe4SiJGk2HeMHrPmxucx7XG2ZGc2Jz9APe+Wip54VXs9pXPw== X-Received: by 2002:a65:6455:: with SMTP id s21-v6mr602610pgv.394.1531369297751; Wed, 11 Jul 2018 21:21:37 -0700 (PDT) From: Shubham Jain To: patchew-devel@redhat.com Date: Thu, 12 Jul 2018 09:51:15 +0530 Message-Id: <20180712042120.2831-2-shubhamjain7495@gmail.com> In-Reply-To: <20180712042120.2831-1-shubhamjain7495@gmail.com> References: <20180712042120.2831-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 12 Jul 2018 04:21:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 12 Jul 2018 04:21:38 +0000 (UTC) for IP:'209.85.192.196' DOMAIN:'mail-pf0-f196.google.com' HELO:'mail-pf0-f196.google.com' FROM:'shubhamjain7495@gmail.com' RCPT:'' X-RedHat-Spam-Score: 3.05 *** (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_WEB, SPF_PASS, T_DKIM_INVALID) 209.85.192.196 mail-pf0-f196.google.com 209.85.192.196 mail-pf0-f196.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH v5 1/6] Handling cookies to use REST api X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 12 Jul 2018 04:21:54 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" - Disabled CSRF authentication until OAuth authentication, since DRF leads = to csrf error while handling sessionauthentication. --- api/rest.py | 6 ++++++ patchew-cli | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/api/rest.py b/api/rest.py index 9ec0ae8..45dab6e 100644 --- a/api/rest.py +++ b/api/rest.py @@ -25,6 +25,12 @@ from rest_framework.response import Response import rest_framework from mbox import addr_db_to_rest, MboxMessage from rest_framework.parsers import JSONParser, BaseParser +from rest_framework.authentication import SessionAuthentication + +class CsrfExemptSessionAuthentication(SessionAuthentication): + + def enforce_csrf(self, request): + return # To not perform the csrf check previously happening =20 SEARCH_PARAM =3D 'q' =20 diff --git a/patchew-cli b/patchew-cli index 174d1e6..9e1fd22 100755 --- a/patchew-cli +++ b/patchew-cli @@ -91,7 +91,7 @@ class SubCommand(object): else: r =3D None return r - + =20 def do(self, args, argv): """Do command""" print("Not implemented") --=20 2.15.1 (Apple Git-101) _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Fri Apr 26 18:26:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1531369320205468.7513404326244; Wed, 11 Jul 2018 21:22:00 -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 609B1C049D5C; Thu, 12 Jul 2018 04:21:58 +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 51EE060D5C; Thu, 12 Jul 2018 04:21:58 +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 42BE04BB78; Thu, 12 Jul 2018 04:21:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6C4LuFm020002 for ; Thu, 12 Jul 2018 00:21:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 622373001A47; Thu, 12 Jul 2018 04:21:56 +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 560C23001A50 for ; Thu, 12 Jul 2018 04:21:53 +0000 (UTC) Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) (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 E9E4330001DB for ; Thu, 12 Jul 2018 04:21:42 +0000 (UTC) Received: by mail-pf0-f194.google.com with SMTP id x10-v6so9915069pfm.4 for ; Wed, 11 Jul 2018 21:21:42 -0700 (PDT) Received: from localhost.localdomain ([112.196.135.182]) by smtp.gmail.com with ESMTPSA id i12-v6sm31294658pgd.87.2018.07.11.21.21.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jul 2018 21:21:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tSCNjXzU3Wmz7VNwtqW9T8UOd7xG2Pz9tirTX+VYCCQ=; b=tSPMyKqgX2Hcetg4xl2W7tKeuAs+Qm794XvNf3/KtXEVP6aGjWeRWwemeW+G+3r2UG ZM5QpAhbe1ZFuF7yOGyWT+9ofb02D8QQul8l0CxaLOHRVHMaJcamOzzNW0GqcpKHVEri xOoVTw1b0wNGPV6ujUR4ZV/SILRrYjU9q1a7ZHa37N4euiJlw5oy/Wdop4mropwZWqOC 1rLXBFZub6We1lF3Zjc/cZ4Be1HcS7LWm5N8K7yNnyLX3HAwq/pog7KxUVawyg5CK5Zj ZNCk8KLT3uhpvmnUCiFtZyIsT5JaZEDxunUi/RPapc6CAc/TOmBCLBUB+rZeDlYJ444e DH+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tSCNjXzU3Wmz7VNwtqW9T8UOd7xG2Pz9tirTX+VYCCQ=; b=IorFrcfGIBXJ35JFrbCrlbjksXPGLXCZx2tjhGNuJeSYQLfelSqxXfrtggQaoiZn47 FVAJLDy1/3a6AgxaNNfiUU4QTSO7IsHmlk0Mf1dHVN5fkBMRIV9WdnXVJY8L0p8pqSD0 qsDkpx5jGUk7IeA5anJ0wDSFygxGpVlLjBHD8pPOj/vhG1H5ajKWR6MRd6C0r9BWUAyv ViGKdxuuwTN+3HP8Ksu3LPHVJe3MguneFnO7a4Kq4jEUUWAdjPHXUZ2XfxSMKdmAgzHW kChOHIezvO1hXLEogSHVCvwT+MuknV7l/jYEjh98ttWPlHOuOKcchd6tveh7k2u18ly4 HbHQ== X-Gm-Message-State: AOUpUlF7/zeV5mBQhEqqNir1wBZ2VmLcfLeLe4Y7ambp/dqsy77mi515 gttH3jdKIrPqorXV6K4KcBWUBQ== X-Google-Smtp-Source: AAOMgpdLupa0W8/yqYgxYNTs05NN1DCMeYxJrwhus5n9qWbUVj+/6zFdHzrSqnz7WxLv0r6b8HiPGQ== X-Received: by 2002:a63:b504:: with SMTP id y4-v6mr36371pge.247.1531369302035; Wed, 11 Jul 2018 21:21:42 -0700 (PDT) From: Shubham Jain To: patchew-devel@redhat.com Date: Thu, 12 Jul 2018 09:51:16 +0530 Message-Id: <20180712042120.2831-3-shubhamjain7495@gmail.com> In-Reply-To: <20180712042120.2831-1-shubhamjain7495@gmail.com> References: <20180712042120.2831-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 12 Jul 2018 04:21:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 12 Jul 2018 04:21:43 +0000 (UTC) for IP:'209.85.192.194' DOMAIN:'mail-pf0-f194.google.com' HELO:'mail-pf0-f194.google.com' FROM:'shubhamjain7495@gmail.com' RCPT:'' X-RedHat-Spam-Score: 3.05 *** (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_WEB, SPF_PASS, T_DKIM_INVALID) 209.85.192.194 mail-pf0-f194.google.com 209.85.192.194 mail-pf0-f194.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH v5 2/6] Changes in Patchew cli to use rest-api X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 12 Jul 2018 04:21:58 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Added general rest_api function to make request to apis and get response. --- patchew-cli | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/patchew-cli b/patchew-cli index 9e1fd22..2069885 100755 --- a/patchew-cli +++ b/patchew-cli @@ -91,6 +91,40 @@ class SubCommand(object): else: r =3D None return r + + def rest_api_do(self, url_cmd, request_method=3D'get', content_type=3D= None, data=3DNone): + logging.debug("API call '%s':" % url_cmd) + logging.debug("data:\n%s" % data) + cookie =3D http.cookiejar.MozillaCookieJar(COOKIE_FILENAME) + try: + cookie.load() + except IOError: + pass + except http.cookiejar.LoadError: + print("Error while loading cookie", COOKIE_FILENAME) + pass + handler =3D urllib.request.HTTPCookieProcessor(cookie) + opener =3D urllib.request.build_opener(handler) + if url_cmd.startswith("http"): + url =3D url_cmd + else: + url =3D self.base_url + '/api/v1/' + url_cmd + '/' + if data is None: + post_data =3D "" + else: + post_data =3D data + req =3D urllib.request.Request(url, data=3Dbytes(post_data, encodi= ng=3D"utf-8"), method=3Drequest_method.upper()) + if content_type is not None: + req.add_header('Content-Type', content_type) + resp =3D opener.open(req) + cookie.save(ignore_discard=3DTrue, ignore_expires=3DTrue) + respdata =3D resp.read() + logging.debug("Server response:\n%s" % (respdata or "")) + if respdata: + r =3D json.loads(respdata.decode("utf-8")) + else: + r =3D None + return r =20 def do(self, args, argv): """Do command""" --=20 2.15.1 (Apple Git-101) _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Fri Apr 26 18:26:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 153136932212313.088614949397083; Wed, 11 Jul 2018 21:22:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 670A8307D84A; Thu, 12 Jul 2018 04:22:01 +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 5734B308BDAE; Thu, 12 Jul 2018 04:22:01 +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 41BD64BB78; Thu, 12 Jul 2018 04:22:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6C4LxmO020305 for ; Thu, 12 Jul 2018 00:21:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id D52321001947; Thu, 12 Jul 2018 04:21:59 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CA78210018FB for ; Thu, 12 Jul 2018 04:21:58 +0000 (UTC) Received: from mail-pl0-f47.google.com (mail-pl0-f47.google.com [209.85.160.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 475EE307D844 for ; Thu, 12 Jul 2018 04:21:47 +0000 (UTC) Received: by mail-pl0-f47.google.com with SMTP id s24-v6so10104932plq.6 for ; Wed, 11 Jul 2018 21:21:47 -0700 (PDT) Received: from localhost.localdomain ([112.196.135.182]) by smtp.gmail.com with ESMTPSA id i12-v6sm31294658pgd.87.2018.07.11.21.21.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jul 2018 21:21:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RH1eIL7Jv7JTQ1lSoNKB9XoKQaSww2z927LBOZFptVM=; b=neOolgA0akjaG+sYNy39eRfJ6tPMAOWJLFgCpEN56mZSj9BUHWwPOC/5Wy3LsknWuQ vkzqz3dQ45J3BUHOx/O+jYSlEiUTbeKwfgCxKmoZszmRDMsxy6X2Y7jFtnyaePAUfukR iXtoee23RUeK/uHx6ObRGq9xUhK+5/lkNcE0R7MsqJCWVe7gsKTYrz8y2UJV4NuDcMus VhdvuuUs3Ppq1YLllTo+kN9Jism2cZgo4vaEBTsa1GUcxWiilqk9I12zlrIjBUPVfGCo 0k1yC/jfURnYMwfSu0M6+esw1RgjdMMUVxbUf5kBS7O1UemSn9CyJGOJNEXIJEuWKXoV wr7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RH1eIL7Jv7JTQ1lSoNKB9XoKQaSww2z927LBOZFptVM=; b=itLSWJHVamZB51is4QztlMeXWAem4EWBq94m1uvvn1RjHM8+ewos0PkBrNFPlxl58W n36lS9koTCU+q1PMsjQqnSfhb7/Db5lHIaPVdwpxyL2Gn0paMWJpCOLHfpJWtMicq6aU rvKHGYsVtw5JVT7KHJCuR4JCUyumWApDKXI7ygNRw8BIjj3RNCwBjCF0bsOCnKdILMXB gsK2fpokzDCeIU+OVGDhbVa5a4zWpVjAq7hsGvhIcD4R4hOG2W9s4+IZXvJHymjt7msV LgirKW/r3m9girQ1tVVp7hqnD/a2RUCEH0BZa8h0DMA1ANmCa6ZGE4oQSOMhtB8Hee9k ut3Q== X-Gm-Message-State: AOUpUlGp0PART8zKrRAigm74ENa9EhwuSFmRHZEmiST5q6bNN8b6VZES Dli49gyRqR1BPPpzqXFP4JHMqw== X-Google-Smtp-Source: AAOMgpezfdYZES7ldZGrkWVsdHrD1d/IstWJLawK7DYd0kUCCkG+D9WC1ou6VvgLQGT+QYqzNjOIug== X-Received: by 2002:a17:902:aa46:: with SMTP id c6-v6mr608146plr.313.1531369306351; Wed, 11 Jul 2018 21:21:46 -0700 (PDT) From: Shubham Jain To: patchew-devel@redhat.com Date: Thu, 12 Jul 2018 09:51:17 +0530 Message-Id: <20180712042120.2831-4-shubhamjain7495@gmail.com> In-Reply-To: <20180712042120.2831-1-shubhamjain7495@gmail.com> References: <20180712042120.2831-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Thu, 12 Jul 2018 04:21:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Thu, 12 Jul 2018 04:21:47 +0000 (UTC) for IP:'209.85.160.47' DOMAIN:'mail-pl0-f47.google.com' HELO:'mail-pl0-f47.google.com' FROM:'shubhamjain7495@gmail.com' RCPT:'' X-RedHat-Spam-Score: 3.05 *** (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_WEB, SPF_PASS, T_DKIM_INVALID) 209.85.160.47 mail-pl0-f47.google.com 209.85.160.47 mail-pl0-f47.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH v5 3/6] Add properties as model field X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Thu, 12 Jul 2018 04:22:01 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" While using legacy api in patchew-cli, get-projects is called in update whi= ch prepare a dictionary of projects using Project fields. In rest, properti= es was missing. --- api/models.py | 2 ++ api/rest.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api/models.py b/api/models.py index e712149..e0c4fa2 100644 --- a/api/models.py +++ b/api/models.py @@ -196,6 +196,8 @@ class Project(models.Model): emit_event("SetProperty", obj=3Dself, name=3Dprop, value=3Dvalue, old_value=3Dold_val) =20 + properties =3D property(get_properties, set_property) =20 + def total_series_count(self): return Message.objects.series_heads(project=3Dself.name).count() =20 diff --git a/api/rest.py b/api/rest.py index 45dab6e..c9a131c 100644 --- a/api/rest.py +++ b/api/rest.py @@ -133,7 +133,7 @@ class ProjectSerializer(serializers.HyperlinkedModelSer= ializer): model =3D Project fields =3D ('resource_uri', 'name', 'mailing_list', 'prefix_tags',= 'url', 'git', \ 'description', 'display_order', 'logo', 'parent_project'= , 'messages', - 'results', 'series') + 'results', 'series', 'properties') =20 messages =3D HyperlinkedIdentityField(view_name=3D'messages-list', loo= kup_field=3D'pk', lookup_url_kwarg=3D'projects_pk') --=20 2.15.1 (Apple Git-101) _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Fri Apr 26 18:26:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 153136932633184.53414397914162; Wed, 11 Jul 2018 21:22:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 808D65AFD2; Thu, 12 Jul 2018 04:22:05 +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 710D3600D1; Thu, 12 Jul 2018 04:22:05 +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 6167B4BB78; Thu, 12 Jul 2018 04:22:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6C4M3PD020327 for ; Thu, 12 Jul 2018 00:22:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id E41773001A54; Thu, 12 Jul 2018 04:22:03 +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 DBCDB3001A47 for ; Thu, 12 Jul 2018 04:22:03 +0000 (UTC) Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) (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 7A8F3C057FA2 for ; Thu, 12 Jul 2018 04:21:52 +0000 (UTC) Received: by mail-pf0-f196.google.com with SMTP id b17-v6so19785387pfi.0 for ; Wed, 11 Jul 2018 21:21:52 -0700 (PDT) Received: from localhost.localdomain ([112.196.135.182]) by smtp.gmail.com with ESMTPSA id i12-v6sm31294658pgd.87.2018.07.11.21.21.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jul 2018 21:21:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XS3y5g5NPy8qnQSqrHw4ufA9JHOcW2CdhLFrKP5qMpg=; b=VYX5433aHk8IPwGS7oSt5uXR28m0sNTBvxY0OG9ZXuSMx5I7wX0D/sQIOygKlJMUHk HTx1lpF36jdsUt7avRq4AsuHt4tkg4HC8o7xSlEJ8ABWhZSE/2LtbuegSadbDUS58Vl0 irjBOuDQe9FhCGJcFiJeavYNSYPbc67UjL74xQyTu8evvrClrMGcBGIX+bxq+V9Ya72M Vq/+9FhIhL4p3Y51xPQVdWRzjrFMfiIpsH13015RFZqN2SpB3N6dQICeWTSqRdcKkHJ3 emnNTie9/7r/iqYCO5Z6Kr28c+HLuUeGOrbup6P3gOXqEVwqHsKkfwea9Iudiv+//i4A lErA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XS3y5g5NPy8qnQSqrHw4ufA9JHOcW2CdhLFrKP5qMpg=; b=S16S6+LO1KZh4DmwFrqAwdleSTgiKXk4rTfqDmNJpPm5VuMxfVHwMRSvErk4i4HJuw JjKof3D0QEySW11QMEKKYEkJH5cCGGw1m9potfhkx7ifEV+YIOTFpHK/jkWSfB/ml2yq gz25azuJuYYoeO8DAniUOLOp37gQJBdTecF8NY6pID3UzLIl2RqydBQKvRm7UuUfuVYv +xNbsckYlZjox6sGz33HusHjP1GENB1pJDjM8xMGxdmcQGdedYP8Abvib8xKH495l412 IX4xW76WqGfI8wkqkxk90OJmhq176XGLfVRWoBwfY/Mob/Pn1+2LigtQkgqlI8Zsmqy/ rYDQ== X-Gm-Message-State: AOUpUlHKD88h2K2lTJwsi1VNo2M4TcxM/U0rykxilLi035rZCt8B0eo9 11RQzyoOZS0x/iBpjIicqPT5jg== X-Google-Smtp-Source: AAOMgpeRmHPygP9520h2pV+lPygcFjWT03G3iQ/OEt5DzJYvr5O4Mujq9qMkJBAHK1MaJkJqIUxCtA== X-Received: by 2002:a63:f919:: with SMTP id h25-v6mr584184pgi.401.1531369311562; Wed, 11 Jul 2018 21:21:51 -0700 (PDT) From: Shubham Jain To: patchew-devel@redhat.com Date: Thu, 12 Jul 2018 09:51:18 +0530 Message-Id: <20180712042120.2831-5-shubhamjain7495@gmail.com> In-Reply-To: <20180712042120.2831-1-shubhamjain7495@gmail.com> References: <20180712042120.2831-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 12 Jul 2018 04:21:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 12 Jul 2018 04:21:52 +0000 (UTC) for IP:'209.85.192.196' DOMAIN:'mail-pf0-f196.google.com' HELO:'mail-pf0-f196.google.com' FROM:'shubhamjain7495@gmail.com' RCPT:'' X-RedHat-Spam-Score: 3.05 *** (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_WEB, SPF_PASS, T_DKIM_INVALID) 209.85.192.196 mail-pf0-f196.google.com 209.85.192.196 mail-pf0-f196.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH v5 4/6] Make Patchew cli's Project use rest api X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 12 Jul 2018 04:22:05 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Make ProjectCommand use rest_api_do instead of api_do --- api/rest.py | 1 + patchew-cli | 38 +++++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/api/rest.py b/api/rest.py index c9a131c..3045516 100644 --- a/api/rest.py +++ b/api/rest.py @@ -146,6 +146,7 @@ class ProjectsViewSet(viewsets.ModelViewSet): queryset =3D Project.objects.all().order_by('id') serializer_class =3D ProjectSerializer permission_classes =3D (PatchewPermission,) + authentication_classes =3D (CsrfExemptSessionAuthentication, ) =20 @action(methods=3D['post'], detail=3DTrue, permission_classes=3D[Impor= tPermission]) def update_project_head(self, request, pk=3DNone): diff --git a/patchew-cli b/patchew-cli index 2069885..8029751 100755 --- a/patchew-cli +++ b/patchew-cli @@ -255,11 +255,11 @@ class ProjectCommand(SubCommand): parser.add_argument("--verbose", "-v", action=3D"store_true", help=3D"Show details about projects") args =3D parser.parse_args(argv) - r =3D self.api_do("get-projects") + r =3D self.rest_api_do(url_cmd=3D"projects", request_method=3D'get= ') if args.raw: print(json.dumps(r, indent=3D2, separators=3D",:")) return 0 - for p in r: + for p in r['results']: print(p["name"]) if args.verbose: for k, v in p.items(): @@ -273,8 +273,8 @@ class ProjectCommand(SubCommand): parser.add_argument("name", nargs=3D"+", help=3D"The name of project to show info") args =3D parser.parse_args(argv) - r =3D self.api_do("get-projects") - for p in r: + r =3D self.rest_api_do(url_cmd=3D"projects", request_method=3D'get= ') + for p in r['results']: if not p["name"] in args.name: continue if len(args.name) > 1: @@ -297,12 +297,15 @@ class ProjectCommand(SubCommand): parser.add_argument("--desc", "-d", default=3D"", help=3D"Project short discription") args =3D parser.parse_args(argv) - self.api_do("add-project", - name=3Dargs.name, - mailing_list=3Dargs.mailing_list, - url=3Dargs.url, - git=3Dargs.git, - description=3Dargs.desc) + data =3D {'name': args.name, + 'mailing_list': args.mailing_list, + 'url': args.url, + 'git': args.git, + 'description': args.desc} + self.rest_api_do(url_cmd=3D"projects", + request_method=3D'post', + content_type=3D'application/json', + data=3Djson.dumps(data)) =20 def update_one_project(self, wd, project): logging.info("Updating project '%s'", project["name"]) @@ -354,16 +357,21 @@ class ProjectCommand(SubCommand): except Exception as e: logging.warn("Failed to push the new head to patchew mirro= r: %s", str(e)) - self.api_do("update-project-head", project=3Dproject["name"], - old_head=3Dold_head, - new_head=3Dnew_head, - message_ids=3Dmsgids) + url =3D project['resource_uri'] + "update_project_head/" + data =3D {"old_head": old_head, + "new_head": new_head, + "message_ids": msgids} + self.rest_api_do(url, request_method=3D'post', + content_type=3D'application/json', + data=3Djson.dumps(data)) + =20 def update_project(self, argv): parser =3D argparse.ArgumentParser() parser.add_argument("--name", "-n", help=3D"Name of the project") args =3D parser.parse_args(argv) - projects =3D self.api_do("get-projects", name=3Dargs.name) + r =3D self.rest_api_do(url_cmd=3D"projects", request_method=3D'get= ') + projects =3D [p for p in r['results'] if p['name'] =3D=3D args.nam= e or args.name =3D=3D None] wd =3D tempfile.mkdtemp() logging.debug("TMPDIR: %s", wd) try: --=20 2.15.1 (Apple Git-101) _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Fri Apr 26 18:26:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1531369334388690.1746052875071; Wed, 11 Jul 2018 21:22: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 AACF33082A2B; Thu, 12 Jul 2018 04:22:13 +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 9DE515D9CA; Thu, 12 Jul 2018 04:22:13 +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 91DAA18037EC; Thu, 12 Jul 2018 04:22:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6C4MC4d020338 for ; Thu, 12 Jul 2018 00:22:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 699D8308BDB0; Thu, 12 Jul 2018 04:22:12 +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 6085F308BDAE for ; Thu, 12 Jul 2018 04:22:09 +0000 (UTC) Received: from mail-pl0-f47.google.com (mail-pl0-f47.google.com [209.85.160.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6CE9C37EE0 for ; Thu, 12 Jul 2018 04:21:58 +0000 (UTC) Received: by mail-pl0-f47.google.com with SMTP id 30-v6so10097043pld.13 for ; Wed, 11 Jul 2018 21:21:58 -0700 (PDT) Received: from localhost.localdomain ([112.196.135.182]) by smtp.gmail.com with ESMTPSA id i12-v6sm31294658pgd.87.2018.07.11.21.21.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jul 2018 21:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2AFKMuJVHP67SFWiS/hXy8sMNjcYReU7LXL82qEjEw8=; b=m6OZZ9rpLhJ5s0EeLITay/vXFy091h0XBklcyimbCbDlVn7HwePrmCSs3f+hsXpls6 9fQ7RJMKXaWCaIBnBw6bk8o60neneD/gpVac4dpY3/d2emOKMBaQtn/Fi6W7RXnJVQp4 IFCbDKqD4V6bgTE/OViL/TR38DDlSSeNiot89PwOLqFZft3IuyFVTbt5jG7txSCQTCzk P7WOi0x5IDAbT0afURrQKabis0CfshvVFfmzj8eeuEBWxoIV/20aG18bPRcUdlv2ucxd i65GiuGStBwmpDwtYhftsZLfENmLQe4NJojaAjb95KHpRTCVZYBqH6RW2ph9UDRIdfB1 JgSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2AFKMuJVHP67SFWiS/hXy8sMNjcYReU7LXL82qEjEw8=; b=liWjXcsQbaa3gkSCzA8QhFUjh8NaiWygww//x4ZkSBnSE/q6dqTYg2YfDk3cXzG3Ve mvtWuRrurUq2gqXRiikVonWWgRxpACAA+g3RmV+Kqd6Kz62Qu8l0KskidyBSwX2GO6Ov M7VWMnQqRNh7kYZMIEAp5QUdjpfHnIvfeMbw0+Oi5Ecrnro31cVaiq+1hNLfG/4s0k2A Kg+XP3Tjl3tu8Po3Gx8+PzzB/k5hBsUklLtLC41c6q9HIevtVjzDjsU+NLKCDluSZ7Tg VFGpKSarDqnG6v8GwruIUXE9T2n3cckb0ldiLtFQXSi0+pnFVzYb1Qr+Kk5PJEih6/8J yhbA== X-Gm-Message-State: AOUpUlG1uTdhcx/cYdDj8JeuTFaa3ET4ZdgOPMVzZhBs8E+REe7XlmNH OKgcGbY3F9HHP+2r75Su2jkzPg== X-Google-Smtp-Source: AAOMgpcU0yoX2HjQ/ZOM3rUYllBqXAZCFvQGldzljnFBkXrCnD7HhBRsYtFkolcMy8hIQFrlRIullQ== X-Received: by 2002:a17:902:be0d:: with SMTP id r13-v6mr610009pls.299.1531369317402; Wed, 11 Jul 2018 21:21:57 -0700 (PDT) From: Shubham Jain To: patchew-devel@redhat.com Date: Thu, 12 Jul 2018 09:51:19 +0530 Message-Id: <20180712042120.2831-6-shubhamjain7495@gmail.com> In-Reply-To: <20180712042120.2831-1-shubhamjain7495@gmail.com> References: <20180712042120.2831-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 12 Jul 2018 04:21:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 12 Jul 2018 04:21:58 +0000 (UTC) for IP:'209.85.160.47' DOMAIN:'mail-pl0-f47.google.com' HELO:'mail-pl0-f47.google.com' FROM:'shubhamjain7495@gmail.com' RCPT:'' X-RedHat-Spam-Score: 3.05 *** (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_WEB, SPF_PASS, T_DKIM_INVALID) 209.85.160.47 mail-pl0-f47.google.com 209.85.160.47 mail-pl0-f47.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH v5 5/6] Make Delete Command use REST X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 12 Jul 2018 04:22:13 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Make patchew-cli's delete use REST api and added the missing test for delete --- api/rest.py | 2 ++ patchew-cli | 16 +++++++++++++++- tests/patchewtest.py | 3 +++ tests/test_message.py | 15 +++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/api/rest.py b/api/rest.py index 3045516..d714d09 100644 --- a/api/rest.py +++ b/api/rest.py @@ -320,6 +320,8 @@ class SeriesViewSet(BaseMessageViewSet): =20 class ProjectSeriesViewSet(ProjectMessagesViewSetMixin, SeriesViewSet, mixins.DestroyModelMixin): + authentication_classes =3D (CsrfExemptSessionAuthentication, ) + =20 def collect_patches(self, series): if series.is_patch: patches =3D [series] diff --git a/patchew-cli b/patchew-cli index 8029751..cb0b650 100755 --- a/patchew-cli +++ b/patchew-cli @@ -181,7 +181,21 @@ class DeleteCommand(SubCommand): if not argv and not args.all: print("Must specify --all to delete all patches") return 1 - self.api_do("delete", terms=3Dargv) + series_list =3D [] + if len(argv)=3D=3D0: + resp =3D self.rest_api_do("projects") + for project in len(resp['result']): + url =3D project['series'] + series_resp =3D self.rest_api_do(url) + series_list =3D series_list + series_resp['results'] + else: + for term in argv: + url =3D str(self.base_url) + "/api/v1/series/?q=3D" + term + series_resp =3D self.rest_api_do(url) + series_list =3D series_list + series_resp['results'] + for series in series_list: + url =3D series['resource_uri'] + self.rest_api_do(url, request_method=3D'delete') return 0 =20 class ImportCommand(SubCommand): diff --git a/tests/patchewtest.py b/tests/patchewtest.py index 5bed3b9..847b3f9 100644 --- a/tests/patchewtest.py +++ b/tests/patchewtest.py @@ -100,6 +100,9 @@ class PatchewTestCase(django.test.LiveServerTestCase): def cli_import(self, mbox, rc=3D0): self.check_cli(["import", self.get_data_path(mbox)], rc) =20 + def cli_delete(self, terms, rc=3D0): + self.check_cli(["delete", terms], rc) + def get_data_path(self, fname): r =3D tempfile.NamedTemporaryFile(dir=3DRUN_DIR, prefix=3D"test-da= ta-", delete=3DFalse) d =3D os.path.join(BASE_DIR, "tests", "data", fname) diff --git a/tests/test_message.py b/tests/test_message.py index 9448aee..4b60c1d 100755 --- a/tests/test_message.py +++ b/tests/test_message.py @@ -10,6 +10,7 @@ =20 import time import datetime +import json from tests.patchewtest import PatchewTestCase, main =20 class ProjectTest(PatchewTestCase): @@ -40,6 +41,20 @@ class ProjectTest(PatchewTestCase): age =3D message.get_age() self.assertEqual(age, "1 day") =20 + def test_delete(self): + self.cli_login() + self.add_project("QEMU", "qemu-devel@nongnu.org") + self.cli_import("0002-unusual-cased-tags.mbox.gz") + self.cli_import("0004-multiple-patch-reviewed.mbox.gz") + a, b =3D self.check_cli(["search", "-r", "-o", "subject,properties= ,message-id"]) + ao =3D json.loads(a)[0] + self.assertEqual(["Fam Zheng", "famz@redhat.com"], + ao["properties"]["reviewers"][0]) + self.cli_delete("from:Fam") + a, b =3D self.check_cli(["search", "-r", "-o", "message-id"]) + ao =3D json.loads(a)[0] + self.assertEqual("1469192015-16487-1-git-send-email-berrange@redha= t.com", ao['message-id']) + def test_asctime(self): from api.models import Message message =3D Message() --=20 2.15.1 (Apple Git-101) _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Fri Apr 26 18:26:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1531369342346167.60333718753213; Wed, 11 Jul 2018 21:22:22 -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 83A8C3086265; Thu, 12 Jul 2018 04:22:21 +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 703A35D75A; Thu, 12 Jul 2018 04:22: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 622784A460; Thu, 12 Jul 2018 04:22:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6C4MKxN020349 for ; Thu, 12 Jul 2018 00:22:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 77EDBC0D1F; Thu, 12 Jul 2018 04:22:20 +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 703D3C0D02 for ; Thu, 12 Jul 2018 04:22:18 +0000 (UTC) Received: from mail-pl0-f49.google.com (mail-pl0-f49.google.com [209.85.160.49]) (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 DACA030832E7 for ; Thu, 12 Jul 2018 04:22:07 +0000 (UTC) Received: by mail-pl0-f49.google.com with SMTP id b1-v6so10107176pls.5 for ; Wed, 11 Jul 2018 21:22:07 -0700 (PDT) Received: from localhost.localdomain ([112.196.135.182]) by smtp.gmail.com with ESMTPSA id i12-v6sm31294658pgd.87.2018.07.11.21.22.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jul 2018 21:22:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8VtzSrpbwV9DVLhKb7Zyfszac8XVo7czRmhTzyy53LI=; b=D/Ww0WVosFGTOH6/u8ZuoZ02Kx/fmHh8ak6hIhq3q8UY+pwPh0M8Mg97NbZKTSUob5 s0SQAa7gTZBP5t4mi3k7m6bFRXusyOWovmtuNWjx7UvIIQ2KXhL3+NEd2DvAAJRAH/RF ofQE0KhlUygPgKvMceBPchZ4AVSUej0PavAamb1TRnm21+SuE9GZ6DsPRYG+UrYw2k0h 9gVEngLAThSQXnYsultPLF9Z2GUPth2UVwtC8j8UzOHDB6ZpA9dAo4vo5Vps/Wrm3wbe Z6RvrXwnZfD5CsB7A7fJBe2sg6uI2mOqrYXol5/UXHwY5NHK0v+FPYXhirp2ztKgfXx6 jovg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8VtzSrpbwV9DVLhKb7Zyfszac8XVo7czRmhTzyy53LI=; b=Zt7U+/aa0rPG1KcfozGk47xkVFo/HCzJUJRFdO9UI83zPYKhMQSJ9+5dzz9JvHabEC /K8clrx9vWZ53VAFn1WJXoTsiQWYX/lE9ZOao6NznsieuLM0/75dUAhefdHy92RYkEZQ mdHuz92DMkA/nvaCj2KCxRcDS4W9SJQIJ3sjMywkSwruWNT0mxx/zgXxEOJHe8csL1Xy ZDw8qHLoGabbfscKM7Ph9K02q9D+ww6diIIb5tS3kQlOuoUSz6lIx+Vux61ugf3jJhqa eGQmMlEtjSkNgqB1Y+e6wL5lAcxaDJZuehr4s26NZKCViBvQwzsxs3t6XXsWjZyfxDFR y6Sw== X-Gm-Message-State: AOUpUlGY15fByvYOO3o18uK2Tbp7sA0GVSG54EEC0CIdmB3tTlrSrjGI Jylz5XFwbAX6ZSVvD+4zHXU/3g== X-Google-Smtp-Source: AAOMgpcrlBVhUFmY8uktd8a+RLRQKViOjWsoEe+veqWg7N5c9NS+g0bGlusmcpUE9bWTJBl9UkKonw== X-Received: by 2002:a17:902:1007:: with SMTP id b7-v6mr612966pla.277.1531369326936; Wed, 11 Jul 2018 21:22:06 -0700 (PDT) From: Shubham Jain To: patchew-devel@redhat.com Date: Thu, 12 Jul 2018 09:51:20 +0530 Message-Id: <20180712042120.2831-7-shubhamjain7495@gmail.com> In-Reply-To: <20180712042120.2831-1-shubhamjain7495@gmail.com> References: <20180712042120.2831-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 12 Jul 2018 04:22:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 12 Jul 2018 04:22:08 +0000 (UTC) for IP:'209.85.160.49' DOMAIN:'mail-pl0-f49.google.com' HELO:'mail-pl0-f49.google.com' FROM:'shubhamjain7495@gmail.com' RCPT:'' X-RedHat-Spam-Score: 3.051 *** (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_WEB, SPF_PASS, T_DKIM_INVALID) 209.85.160.49 mail-pl0-f49.google.com 209.85.160.49 mail-pl0-f49.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.44 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH v5 6/6] Make Import Command use Rest X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 12 Jul 2018 04:22:21 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Make patchew-cli's Import REST apis. For an authenticated but unauthorised = user the exit status would be 1 ie when no projects are imported. Now importing same message to a project again would not give 404 error. Also changed a test case in test_tags accordingly. --- api/models.py | 3 +++ api/rest.py | 1 + patchew-cli | 18 +++++++++++++----- tests/test_tags.py | 4 +--- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/api/models.py b/api/models.py index e0c4fa2..b3ba457 100644 --- a/api/models.py +++ b/api/models.py @@ -361,6 +361,9 @@ class MessageManager(models.Manager): def create(self, project, **validated_data): mbox =3D validated_data.pop('mbox') m =3D MboxMessage(mbox) + msg =3D Message.objects.filter(message_id=3Dm.get_message_id(), pr= oject=3Dproject).first() + if msg is not None: + return msg msg =3D Message(**validated_data) if 'in_reply_to' not in validated_data: msg.in_reply_to =3D m.get_in_reply_to() or "" diff --git a/api/rest.py b/api/rest.py index d714d09..a9b6be3 100644 --- a/api/rest.py +++ b/api/rest.py @@ -423,6 +423,7 @@ class MessagesViewSet(BaseMessageViewSet): serializer_class =3D MessageSerializer permission_classes =3D (permissions.IsAuthenticatedOrReadOnly,) parser_classes =3D (JSONParser, MessagePlainTextParser, ) + authentication_classes =3D (CsrfExemptSessionAuthentication, ) =20 def create(self, request, *args, **kwargs): m =3D MboxMessage(request.data['mbox']) diff --git a/patchew-cli b/patchew-cli index cb0b650..f8d6e57 100755 --- a/patchew-cli +++ b/patchew-cli @@ -221,11 +221,16 @@ class ImportCommand(SubCommand): print("[OLD] " + mo["Subject"]) return print("[NEW] " + mo["Subject"]) - r =3D self.api_do("import", mboxes=3D[mo.as_string()]) - for p in r: - if p not in projects: - projects.add(p) - print(p) + for mbox in [mo.as_string()]: + r =3D self.rest_api_do(url_cmd=3D"messages", + request_method=3D'post', + content_type=3D'message/rfc822', + data=3Dmbox) + projects_list =3D [x['resource_uri'].split("messages")[0] = for x in r['results']] + for p in projects_list: + if p not in projects: + projects.add(p) + print(p) if ff: open(ff, "wb").close() =20 @@ -251,6 +256,9 @@ class ImportCommand(SubCommand): for f in args.file: try: import_one(f) + if len(projects) =3D=3D 0: + print("The message was not imported to any project. Pe= rhaps you're not logged in as an importer or maintainer") + r =3D 1 except: print("Error in importing:", f) traceback.print_exc() diff --git a/tests/test_tags.py b/tests/test_tags.py index 6c162de..c91e9c1 100755 --- a/tests/test_tags.py +++ b/tests/test_tags.py @@ -22,9 +22,7 @@ class ImportTest(PatchewTestCase): self.p.save() =20 def test_import_one(self): - resp =3D self.apply_and_retrieve('0017-qemu-web-is-not-qemu.mbox.g= z', - self.p.id, '1504250391-6353-1-git-s= end-email-thuth@redhat.com') - self.assertEquals(resp.status_code, 404) + self.cli_import("0017-qemu-web-is-not-qemu.mbox.gz", rc=3D1) =20 def test_rest_single(self): resp =3D self.apply_and_retrieve('0003-single-patch-reviewed.mbox.= gz', --=20 2.15.1 (Apple Git-101) _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel