From patchwork Fri Sep 21 17:51:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 973380 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42H1RS1SJFz9sCS for ; Sat, 22 Sep 2018 03:53:24 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="sadLo+Vz"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42H1RR6kN5zF3SF for ; Sat, 22 Sep 2018 03:53:23 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="sadLo+Vz"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=185.234.75.9; helo=relay002.mxroute.com; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="sadLo+Vz"; dkim-atps=neutral Received: from relay002.mxroute.com (relay002.mxroute.com [185.234.75.9]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42H1PZ6X4wzF3R1 for ; Sat, 22 Sep 2018 03:51:45 +1000 (AEST) Received: from filter002.mxroute.com (unknown [185.133.192.179]) by relay002.mxroute.com (Postfix) with ESMTP id 368063F0F1 for ; Fri, 21 Sep 2018 17:51:13 +0000 (UTC) Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter002.mxroute.com (Postfix) with ESMTPS id 21AD53F39E for ; Fri, 21 Sep 2018 17:51:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Bgq/ByNA4XmJSmrpKvNBMXxgiKWcoQ1rffJqxBWmas4=; b=sadLo+Vza/7J8wESIzPFC2lmtU /ZYpaDa+adFrMSROevWGjXDcXOJTSWijwvs1kGWZw+F69YK7e7Nd3BDUgWVFu7IvC9Z6dnpSzgQQG 0jebl2R27tLBtVNqLL6BJ83/Y/mGlTSLS6tbS334wOEyWR1qC9IrPfhMZPGjym8yhCJ58JMfjpW70 K7+uRTNC+dowa0izN6S3L943QCVHCw1Bh5mXEMHtCgcRBKLnhfZdc3VuIj1SI5PVaWzuIFr8oRtYf T/lJHndMxkS2XGGcggtU+w80xBjD3eFfYpCDgU1ef4q9Oy3N2OK7c0FYMBZ2BnahL5DGQAHa5Kfte pi2ifGrw==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH v3 5/5] views: Add support for boolean 'series' parameters Date: Fri, 21 Sep 2018 18:51:05 +0100 Message-Id: <20180921175105.18000-6-stephen@that.guru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921175105.18000-1-stephen@that.guru> References: <20180921175105.18000-1-stephen@that.guru> X-AuthUser: stephen@that.guru X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Previously, we allowed users to download patch mboxes with dependencies included using a 'series' parameter. This accepted either a numeric ID, corresponding to the ID of the patch series that dependencies should be included from, or a wildcard value ('*'). /patch/{patchID}/mbox/?series=123 /patch/{patchID}/mbox/?series=* With switch to a 1:N series-patch relationship, this is clearly unnecessary now but must be retained to avoid breaking users. However, that doesn't mean we can't things a little clearer. Add support for boolean parameters, which make more sense for this kind of relationship: /patch/{patchID}/mbox/?series=true /patch/{patchID}/mbox/?series=1 /patch/{patchID}/mbox/?series=false /patch/{patchID}/mbox/?series=0 Signed-off-by: Stephen Finucane --- TODO: I'm not sure if I should do this or introduce a new parameter (maybe 'dependencies'?). Thoughts? --- patchwork/tests/test_mboxviews.py | 17 +++++++++++++++++ patchwork/views/patch.py | 2 +- patchwork/views/utils.py | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/patchwork/tests/test_mboxviews.py b/patchwork/tests/test_mboxviews.py index 5c29226b..8f6a51f2 100644 --- a/patchwork/tests/test_mboxviews.py +++ b/patchwork/tests/test_mboxviews.py @@ -223,6 +223,23 @@ class MboxSeriesDependencies(TestCase): self.assertContains(response, patch_a.content) self.assertContains(response, patch_b.content) + def test_patch_with_boolean_series(self): + _, patch_a, patch_b = self._create_patches() + + for value in ('true', '1'): + response = self.client.get('%s?series=%s' % ( + reverse('patch-mbox', args=[patch_b.id]), value)) + + self.assertContains(response, patch_a.content) + self.assertContains(response, patch_b.content) + + for value in ('false', '0'): + response = self.client.get('%s?series=%s' % ( + reverse('patch-mbox', args=[patch_b.id]), value)) + + self.assertNotContains(response, patch_a.content) + self.assertContains(response, patch_b.content) + def test_patch_with_invalid_series(self): series, patch_a, patch_b = self._create_patches() diff --git a/patchwork/views/patch.py b/patchwork/views/patch.py index 277b2816..446a0c4b 100644 --- a/patchwork/views/patch.py +++ b/patchwork/views/patch.py @@ -130,7 +130,7 @@ def patch_mbox(request, patch_id): series_id = request.GET.get('series') response = HttpResponse(content_type='text/plain') - if series_id: + if series_id and series_id.lower() not in ('false', '0'): if not patch.series: raise Http404('Patch does not have an associated series. This is ' 'because the patch was processed with an older ' diff --git a/patchwork/views/utils.py b/patchwork/views/utils.py index 3c5d2982..d6f54ea6 100644 --- a/patchwork/views/utils.py +++ b/patchwork/views/utils.py @@ -127,7 +127,7 @@ def series_patch_to_mbox(patch, series_id): Returns: A string for the mbox file. """ - if series_id != '*': + if series_id.lower() not in ('*', 'true', '1'): try: series_id = int(series_id) except ValueError: