From nobody Tue Oct 22 22:19:56 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1522174688051794.4368248384249; Tue, 27 Mar 2018 11:18:08 -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 1B0D223E6C1; Tue, 27 Mar 2018 18:18:07 +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 10F57600D2; Tue, 27 Mar 2018 18:18:07 +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 0793A181BA02; Tue, 27 Mar 2018 18:18:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2RII57v013783 for ; Tue, 27 Mar 2018 14:18:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6EB4E2026985; Tue, 27 Mar 2018 18:18:05 +0000 (UTC) Received: from lemon.usersys.redhat.com (ovpn-12-44.pek2.redhat.com [10.72.12.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A5B52026E03 for ; Tue, 27 Mar 2018 18:18:04 +0000 (UTC) From: Fam Zheng To: patchew-devel@redhat.com Date: Wed, 28 Mar 2018 02:17:55 +0800 Message-Id: <20180327181756.23938-2-famz@redhat.com> In-Reply-To: <20180327181756.23938-1-famz@redhat.com> References: <20180327181756.23938-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 1/2] api: Expose project properties to importers 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.29]); Tue, 27 Mar 2018 18:18:07 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Importers need it for project update. Introduce and use Project.properties_visible() method to fix the permission problem. Signed-off-by: Fam Zheng --- api/models.py | 4 ++++ api/views.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/api/models.py b/api/models.py index a672bd4..955a91c 100644 --- a/api/models.py +++ b/api/models.py @@ -134,6 +134,10 @@ class Project(models.Model): return True return False =20 + def properties_visible(self, user): + return self.maintained_by(user) or \ + user.groups.filter(name=3D'importers').exists() + def recognizes(self, m): """Test if @m is considered a message in this project""" addr_ok =3D False diff --git a/api/views.py b/api/views.py index 2d84be8..122a4d9 100644 --- a/api/views.py +++ b/api/views.py @@ -85,7 +85,7 @@ class ListProjectView(APIView): "git": p.git, "description": p.description, } - if p.maintained_by(request.user): + if p.properties_visible(request.user): ret["properties"] =3D p.get_properties() return ret =20 @@ -111,7 +111,7 @@ class GetProjectPropertiesView(APIView): =20 def handle(self, request, project): po =3D Project.objects.get(name=3Dproject) - if not po.maintained_by(request.user): + if not po.properties_visible(request.user): raise PermissionDenied("Access denied to this project") return po.get_properties() =20 --=20 2.14.3 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel