From nobody Sun Jan 5 05:45:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=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 1533726771216563.759573281688; Wed, 8 Aug 2018 04:12:51 -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 C68FD4E327; Wed, 8 Aug 2018 11:12:49 +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 B541A308BDB2; Wed, 8 Aug 2018 11:12:49 +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 A6CF64BB78; Wed, 8 Aug 2018 11:12:49 +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 w78BCmAM003398 for ; Wed, 8 Aug 2018 07:12:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id BB5216269F; Wed, 8 Aug 2018 11:12:48 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B2EB52C334 for ; Wed, 8 Aug 2018 11:12:44 +0000 (UTC) Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 780E785540 for ; Wed, 8 Aug 2018 11:12:43 +0000 (UTC) Received: by mail-pf1-f169.google.com with SMTP id a26-v6so986563pfo.4 for ; Wed, 08 Aug 2018 04:12:43 -0700 (PDT) Received: from localhost.localdomain ([182.74.40.122]) by smtp.gmail.com with ESMTPSA id 1-v6sm11432969pfk.134.2018.08.08.04.12.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Aug 2018 04:12: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=Pa3lpjtpdQlcXgZ1haZTjsXqjPZeCZQqWFP8nlAdEMs=; b=E5UHkczsFUOlAhIHitkSlHdTUobZ0kzc31d0Y35wFUaAxMVKYCIKgC+7yrvh9vlAvF h1HzGdd3zVObYEWjuRu0OwNp8xDtcsAhbsImgYxqbdTMzsGj7dz8GuFaBZo8ii6/LoaR 78N+3qdIciQxt2N/HjM2sqTOQh5bmMaRGi2HEoZ5WgiRM8kACyDKYCoW9WTuCX2qbBuQ LmdCLqSlx9n1rgPJ+T4s0KVDTCpN2nb00/RdCj8jdmQN3Adl4y3oMNn6qz+Dv0HDxUs1 5wb9cc+QXRHPx5gviRaLPdLq1/gIZ8vvSzfWDUd5/58P6YJOGz0o0jKTNpxuJLHqDmiR y5CQ== 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=Pa3lpjtpdQlcXgZ1haZTjsXqjPZeCZQqWFP8nlAdEMs=; b=YtGtVW8p+frKThEY5HhU6wdqKqC0n9SnwcYNasuf4jCMh5rv/A5cw4qwmo2ET+sRxE XgY1PDtuwkRf0RYUS5AGlNiB2EyZGvUcwTQ0oQWM2O3uVzpGrLwD0rfdaj5xRbIrE7ZU Q4L1jv+ClzTUaXOjkf4NS2v1iI0/wgOA5WnlY4MDyRRoI+6u/y0C8Vh0G1PSn2Z8hja4 +VxFR4Uavit4LrfJLoga+kGHoQP9MFe8qExOgJgv6IP6uaoMSOuiaONO4yZ9TTQ1nOu9 X6sb8U4DvHXyo9eMNx9z9wDgLCJzJYYh3GJDXXMZtnJmGaT/cW3SUsUkt1XCA429tCHZ h1ow== X-Gm-Message-State: AOUpUlE7iEKG6uxbC6s1dvcVOTgOncIrB+un9NXqEX9WtiUztqhgtX0L ny+alPxByv4LMKFMMTm4vj0L6azwU2I= X-Google-Smtp-Source: AA+uWPy91kemKttilpQAYaFAo0tRRQirmNTSMKKgFkZ+KIZ0vFt4IpYwX9Tog9ptvF02kOipgn1qNg== X-Received: by 2002:a62:4909:: with SMTP id w9-v6mr2513930pfa.154.1533726762475; Wed, 08 Aug 2018 04:12:42 -0700 (PDT) From: Shubham Jain To: patchew-devel@redhat.com Date: Wed, 8 Aug 2018 16:42:24 +0530 Message-Id: <20180808111226.55535-2-shubhamjain7495@gmail.com> In-Reply-To: <20180808111226.55535-1-shubhamjain7495@gmail.com> References: <20180808111226.55535-1-shubhamjain7495@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 08 Aug 2018 11:12:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 08 Aug 2018 11:12:43 +0000 (UTC) for IP:'209.85.210.169' DOMAIN:'mail-pf1-f169.google.com' HELO:'mail-pf1-f169.google.com' FROM:'shubhamjain7495@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.14 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.210.169 mail-pf1-f169.google.com 209.85.210.169 mail-pf1-f169.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH 1/3] Add ability to access projects by name 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.38]); Wed, 08 Aug 2018 11:12:49 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Now projects can also be accessed through urls by /projects/?name=3D --- api/rest.py | 6 ++++++ tests/test_rest.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/api/rest.py b/api/rest.py index a9b6be3..21f4609 100644 --- a/api/rest.py +++ b/api/rest.py @@ -148,6 +148,12 @@ class ProjectsViewSet(viewsets.ModelViewSet): permission_classes =3D (PatchewPermission,) authentication_classes =3D (CsrfExemptSessionAuthentication, ) =20 + def get_queryset(self): + name =3D self.request.query_params.get('name', None) + if name is not None: + return Project.objects.filter(name=3Dname).order_by('id') + return Project.objects.all().order_by('id') + @action(methods=3D['post'], detail=3DTrue, permission_classes=3D[Impor= tPermission]) def update_project_head(self, request, pk=3DNone): """ diff --git a/tests/test_rest.py b/tests/test_rest.py index 980d61a..937a39a 100755 --- a/tests/test_rest.py +++ b/tests/test_rest.py @@ -441,6 +441,12 @@ class RestTest(PatchewTestCase): self.assertEqual(resp.data['results'][3]['resource_uri'], self.PRO= JECT_BASE + 'messages/e0858c00-ccb6-e533-ee3e-9ba84ca45a7b@redhat.com/') self.assertEqual(resp.data['results'][3]['subject'], 'Re: [Qemu-de= vel] [PATCH v4 0/2] Report format specific info for LUKS block driver') =20 + def test_project_filter(self): + resp =3D self.api_client.get(self.REST_BASE + 'projects/?name=3DQE= MU') + project =3D resp.data['results'][0] + self.assertEquals(project['name'], "QEMU") + self.assertEquals(project['mailing_list'], "qemu-devel@nongnu.org") + def test_schema(self): resp =3D self.api_client.get(self.REST_BASE + 'schema/') self.assertEqual(resp.status_code, 200) --=20 2.15.1 (Apple Git-101) _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel