aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVeronika Kabatova <vkabatov@redhat.com>2018-05-03 12:55:16 +0200
committerStephen Finucane <stephen@that.guru>2018-05-03 15:23:49 +0100
commit8d6cc05082cf8fee84932e1e683382824e9b1c28 (patch)
tree8eea5e4e7f8dca3e19fceb42aa1d407a7cb7dc39
parentd2eb1f6d20835713c9560bd55abf6d6da0b91ce2 (diff)
downloadpatchwork-8d6cc05082cf8fee84932e1e683382824e9b1c28.tar
patchwork-8d6cc05082cf8fee84932e1e683382824e9b1c28.tar.gz
Explicitly distinguish between comments on patch and cover
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> Reviewed-by: Stephen Finucane <stephen@that.guru>
-rw-r--r--patchwork/api/cover.py2
-rw-r--r--patchwork/api/patch.py2
-rw-r--r--patchwork/tests/api/test_comment.py4
-rw-r--r--patchwork/urls.py4
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<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 += [