From patchwork Fri Aug 20 04:50:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raxel Gutierrez X-Patchwork-Id: 1518911 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=SbnJ2hi4; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GrTjR23jXz9sWl for ; Fri, 20 Aug 2021 14:50:51 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GrTjR1C2Tz3cSW for ; Fri, 20 Aug 2021 14:50:51 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=SbnJ2hi4; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--raxel.bounces.google.com (client-ip=2607:f8b0:4864:20::f4a; helo=mail-qv1-xf4a.google.com; envelope-from=3ndqfyqukczecviz619916z.x97avex2h9c563ded.9k6vwd.9c1@flex--raxel.bounces.google.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=SbnJ2hi4; dkim-atps=neutral Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4GrTjC3wBZz30MC for ; Fri, 20 Aug 2021 14:50:39 +1000 (AEST) Received: by mail-qv1-xf4a.google.com with SMTP id z8-20020a0ce9880000b02903528f1b338aso6110084qvn.6 for ; Thu, 19 Aug 2021 21:50:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=tu98THFyvy8scUNoDMAkb1Gs6FqwhcfNw88/tLxaDAs=; b=SbnJ2hi4bYzOGXvcBKmfI6VfFOKUYhZ1bud8HXNhacOf8jkON5Y1Xu1iRWfkCuApXm epRqJ9E/BhOrQfLZPqam7bW/EoiQ+NLyPNegDunhKcDhsPUAW7AuPLwvOXZgsgBPe6rT pjviB7SP8LSowFjU8ozyMf2FWqAQQXk65veQdgajBafjACCOLjj1RWW8NLpDZ4kEcHAi yge82LoH7LVPPcQS3gMCXXfshBNli+YdLvWNpBjy0zQBIqoGQHcyX56fVzgo4ItTas58 44DbG0NvDvyyYwG4UVotzVP+BSyKr2MqpNOs6WkkoLORPh4D3oHYSyjMFDMn8GB0JM7L 61GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=tu98THFyvy8scUNoDMAkb1Gs6FqwhcfNw88/tLxaDAs=; b=P/Pa2tyNssNLjk37OuxdUEufEXPqsXk7FZg5/+qznzVWnybFBIaqUqmIP6dvSMWNJH PL6ltlomFTAathP4OZVj8reYdnzxh+9nffbijMCw5THRu7hUGQO+CCAXYIyGiXslK496 s2nJGP2Fl8HRNs3q/m8HadxYCxEszIzLko4zHz0BsKRWO++d4HeFIvzMhiu7ZiUTHR07 YX0iqMmKFOWQ2O/OjEuZTxhp8sV5h8uF8cVcVOiTJ7FAqLvY7j5HUOqu8JjanM36ZBBL dmPnnxpg0mWAOmg1i3daNE7v5RvHp7DBxhvrH/J446c5WqXZt9CfmHxiZ5rnJ6e/Qh0r TWdw== X-Gm-Message-State: AOAM531I72EThmKuhRUTMkh1cIwvyLUknFsYzRRcfq8nLxJ1PKvh461t zByFevMwbd6Y+pEK+eNOsMewugfBXmiTMu0NyIUG2f/MDEzdgqKhdJHDCzh3K89PfCWRCSy1hDu z1T9u6aF5dEpNshTe/ick92GEByMxGQDHFeFiI+G0zpxHHVPQ/OkuiOBT96fZT1EF X-Google-Smtp-Source: ABdhPJwWUj3nz8IO9n5SPgcUscW5Y50pvQneVtLki6WLf26P0GeMo3hjhe9EUcMsD4zDvk5b2Z3rrROx0g== X-Received: from raxel-pw.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2fda]) (user=raxel job=sendgmr) by 2002:a05:6214:291:: with SMTP id l17mr18463230qvv.50.1629435036301; Thu, 19 Aug 2021 21:50:36 -0700 (PDT) Date: Fri, 20 Aug 2021 04:50:23 +0000 In-Reply-To: <20210820045030.3364156-1-raxel@google.com> Message-Id: <20210820045030.3364156-3-raxel@google.com> Mime-Version: 1.0 References: <20210820045030.3364156-1-raxel@google.com> X-Mailer: git-send-email 2.33.0.rc2.250.ged5fa647cd-goog Subject: [PATCH v4 2/9] api: change parameter to for cover comments endpoint From: Raxel Gutierrez To: patchwork@lists.ozlabs.org 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: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Rename cover lookup parameter `pk` to `cover_id` for the cover comments list endpoints to disambiguate from the lookup parameter `comment_id` in upcoming patches which introduces the cover comments detail endpoint. This doesn't affect the user-facing API. Signed-off-by: Raxel Gutierrez Reviewed-by: Stephen Finucane --- patchwork/api/comment.py | 6 +++--- patchwork/api/cover.py | 2 +- patchwork/tests/api/test_comment.py | 4 ++-- patchwork/urls.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/patchwork/api/comment.py b/patchwork/api/comment.py index 0c578b44..5d7a77a1 100644 --- a/patchwork/api/comment.py +++ b/patchwork/api/comment.py @@ -83,14 +83,14 @@ class CoverCommentList(ListAPIView): search_fields = ('subject',) ordering_fields = ('id', 'subject', 'date', 'submitter') ordering = 'id' - lookup_url_kwarg = 'pk' + lookup_url_kwarg = 'cover_id' def get_queryset(self): - if not Cover.objects.filter(pk=self.kwargs['pk']).exists(): + if not Cover.objects.filter(id=self.kwargs['cover_id']).exists(): raise Http404 return CoverComment.objects.filter( - cover=self.kwargs['pk'] + cover=self.kwargs['cover_id'] ).select_related('submitter') diff --git a/patchwork/api/cover.py b/patchwork/api/cover.py index b4a3a8f7..c4355f6b 100644 --- a/patchwork/api/cover.py +++ b/patchwork/api/cover.py @@ -37,7 +37,7 @@ class CoverListSerializer(BaseHyperlinkedModelSerializer): def get_comments(self, cover): return self.context.get('request').build_absolute_uri( - reverse('api-cover-comment-list', kwargs={'pk': cover.id})) + reverse('api-cover-comment-list', kwargs={'cover_id': cover.id})) def to_representation(self, instance): # NOTE(stephenfin): This is here to ensure our API looks the same even diff --git a/patchwork/tests/api/test_comment.py b/patchwork/tests/api/test_comment.py index 59450d8a..53abf8f0 100644 --- a/patchwork/tests/api/test_comment.py +++ b/patchwork/tests/api/test_comment.py @@ -27,7 +27,7 @@ class TestCoverComments(utils.APITestCase): kwargs = {} if version: kwargs['version'] = version - kwargs['pk'] = cover.id + kwargs['cover_id'] = cover.id return reverse('api-cover-comment-list', kwargs=kwargs) @@ -79,7 +79,7 @@ class TestCoverComments(utils.APITestCase): def test_list_invalid_cover(self): """Ensure we get a 404 for a non-existent cover letter.""" resp = self.client.get( - reverse('api-cover-comment-list', kwargs={'pk': '99999'})) + reverse('api-cover-comment-list', kwargs={'cover_id': '99999'})) self.assertEqual(status.HTTP_404_NOT_FOUND, resp.status_code) diff --git a/patchwork/urls.py b/patchwork/urls.py index 1e6c12ab..0180e76d 100644 --- a/patchwork/urls.py +++ b/patchwork/urls.py @@ -337,7 +337,7 @@ if settings.ENABLE_REST_API: name='api-patch-comment-list', ), path( - 'covers//comments/', + 'covers//comments/', api_comment_views.CoverCommentList.as_view(), name='api-cover-comment-list', ),