Skip to content

Commit 8d6cc05

Browse files
veruustephenfin
authored andcommitted
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>
1 parent d2eb1f6 commit 8d6cc05

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

patchwork/api/cover.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def get_mbox(self, instance):
4646

4747
def get_comments(self, cover):
4848
return self.context.get('request').build_absolute_uri(
49-
reverse('api-comment-list', kwargs={'pk': cover.id}))
49+
reverse('api-cover-comment-list', kwargs={'pk': cover.id}))
5050

5151
class Meta:
5252
model = CoverLetter

patchwork/api/patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def get_mbox(self, instance):
9494

9595
def get_comments(self, patch):
9696
return self.context.get('request').build_absolute_uri(
97-
reverse('api-comment-list', kwargs={'pk': patch.id}))
97+
reverse('api-patch-comment-list', kwargs={'pk': patch.id}))
9898

9999
def get_check(self, instance):
100100
return instance.combined_check_state

patchwork/tests/api/test_comment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def api_url(cover, version=None):
4646
kwargs['version'] = version
4747
kwargs['pk'] = cover.id
4848

49-
return reverse('api-comment-list', kwargs=kwargs)
49+
return reverse('api-cover-comment-list', kwargs=kwargs)
5050

5151
def assertSerialized(self, comment_obj, comment_json):
5252
self.assertEqual(comment_obj.id, comment_json['id'])
@@ -85,7 +85,7 @@ def api_url(patch, version=None):
8585
kwargs['version'] = version
8686
kwargs['pk'] = patch.id
8787

88-
return reverse('api-comment-list', kwargs=kwargs)
88+
return reverse('api-patch-comment-list', kwargs=kwargs)
8989

9090
def assertSerialized(self, comment_obj, comment_json):
9191
self.assertEqual(comment_obj.id, comment_json['id'])

patchwork/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,10 @@
283283
api_1_1_patterns = [
284284
url(r'^patches/(?P<pk>[^/]+)/comments/$',
285285
api_comment_views.CommentList.as_view(),
286-
name='api-comment-list'),
286+
name='api-patch-comment-list'),
287287
url(r'^covers/(?P<pk>[^/]+)/comments/$',
288288
api_comment_views.CommentList.as_view(),
289-
name='api-comment-list'),
289+
name='api-cover-comment-list'),
290290
]
291291

292292
urlpatterns += [

0 commit comments

Comments
 (0)