diff mbox series

Explicitly distinguish between comments on patch and cover

Message ID 20180503105516.2590-1-vkabatov@redhat.com
State Accepted
Headers show
Series Explicitly distinguish between comments on patch and cover | expand

Commit Message

Veronika Kabatova May 3, 2018, 10:55 a.m. UTC
From: Veronika Kabatova <vkabatov@redhat.com>

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 <dja@axtens.net>
Signed-off-by: Veronika Kabatova <vkabatov@redhat.com>
---
 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(-)

Comments

Stephen Finucane May 3, 2018, 2:25 p.m. UTC | #1
On Thu, 2018-05-03 at 12:55 +0200, vkabatov@redhat.com wrote:
> From: Veronika Kabatova <vkabatov@redhat.com>
> 
> 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 <dja@axtens.net>
> Signed-off-by: Veronika Kabatova <vkabatov@redhat.com>

Thanks for the quick turn around on this.

Reviewed-by: Stephen Finucane <stephen@that.guru>

and applied.
diff mbox series

Patch

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<pk>[^/]+)/comments/$',
             api_comment_views.CommentList.as_view(),
-            name='api-comment-list'),
+            name='api-patch-comment-list'),
         url(r'^covers/(?P<pk>[^/]+)/comments/$',
             api_comment_views.CommentList.as_view(),
-            name='api-comment-list'),
+            name='api-cover-comment-list'),
     ]
 
     urlpatterns += [