From patchwork Thu May 3 10:55:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Veronika Kabatova X-Patchwork-Id: 907958 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40cBrT5Kfwz9s3G for ; Thu, 3 May 2018 20:55:37 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40cBrT3LS2zF2W2 for ; Thu, 3 May 2018 20:55:37 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=redhat.com (client-ip=66.187.233.73; helo=mx1.redhat.com; envelope-from=vkabatov@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40cBrH0vjCzF2Vp for ; Thu, 3 May 2018 20:55:27 +1000 (AEST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BDA4F40201AF for ; Thu, 3 May 2018 10:55:23 +0000 (UTC) Received: from vkabatova.usersys.redhat.com (unknown [10.43.17.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CE952166BAD; Thu, 3 May 2018 10:55:23 +0000 (UTC) From: vkabatov@redhat.com To: patchwork@lists.ozlabs.org Subject: [PATCH] Explicitly distinguish between comments on patch and cover Date: Thu, 3 May 2018 12:55:16 +0200 Message-Id: <20180503105516.2590-1-vkabatov@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 03 May 2018 10:55:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 03 May 2018 10:55:23 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'vkabatov@redhat.com' RCPT:'' X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.26 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" From: Veronika Kabatova reverse() gets confused when the same view name and kwargs are passed to it, ignoring what endpoint the request originated from. Fix this by using different view names for cover letter and patch comments views. Reported-by: Daniel Axtens Signed-off-by: Veronika Kabatova Reviewed-by: Stephen Finucane --- patchwork/api/cover.py | 2 +- patchwork/api/patch.py | 2 +- patchwork/tests/api/test_comment.py | 4 ++-- patchwork/urls.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/patchwork/api/cover.py b/patchwork/api/cover.py index 7c80064..99cf9e6 100644 --- a/patchwork/api/cover.py +++ b/patchwork/api/cover.py @@ -46,7 +46,7 @@ class CoverLetterListSerializer(BaseHyperlinkedModelSerializer): def get_comments(self, cover): return self.context.get('request').build_absolute_uri( - reverse('api-comment-list', kwargs={'pk': cover.id})) + reverse('api-cover-comment-list', kwargs={'pk': cover.id})) class Meta: model = CoverLetter diff --git a/patchwork/api/patch.py b/patchwork/api/patch.py index d1931c0..028d685 100644 --- a/patchwork/api/patch.py +++ b/patchwork/api/patch.py @@ -94,7 +94,7 @@ class PatchListSerializer(BaseHyperlinkedModelSerializer): def get_comments(self, patch): return self.context.get('request').build_absolute_uri( - reverse('api-comment-list', kwargs={'pk': patch.id})) + reverse('api-patch-comment-list', kwargs={'pk': patch.id})) def get_check(self, instance): return instance.combined_check_state diff --git a/patchwork/tests/api/test_comment.py b/patchwork/tests/api/test_comment.py index 9cad2ad..f79ea46 100644 --- a/patchwork/tests/api/test_comment.py +++ b/patchwork/tests/api/test_comment.py @@ -46,7 +46,7 @@ class TestCoverComments(APITestCase): kwargs['version'] = version kwargs['pk'] = cover.id - return reverse('api-comment-list', kwargs=kwargs) + return reverse('api-cover-comment-list', kwargs=kwargs) def assertSerialized(self, comment_obj, comment_json): self.assertEqual(comment_obj.id, comment_json['id']) @@ -85,7 +85,7 @@ class TestPatchComments(APITestCase): kwargs['version'] = version kwargs['pk'] = patch.id - return reverse('api-comment-list', kwargs=kwargs) + return reverse('api-patch-comment-list', kwargs=kwargs) def assertSerialized(self, comment_obj, comment_json): self.assertEqual(comment_obj.id, comment_json['id']) diff --git a/patchwork/urls.py b/patchwork/urls.py index 1dc4ffc..e90de6b 100644 --- a/patchwork/urls.py +++ b/patchwork/urls.py @@ -283,10 +283,10 @@ if settings.ENABLE_REST_API: api_1_1_patterns = [ url(r'^patches/(?P[^/]+)/comments/$', api_comment_views.CommentList.as_view(), - name='api-comment-list'), + name='api-patch-comment-list'), url(r'^covers/(?P[^/]+)/comments/$', api_comment_views.CommentList.as_view(), - name='api-comment-list'), + name='api-cover-comment-list'), ] urlpatterns += [