Skip to content

Commit 38959ba

Browse files
Raxel Gutierrezdaxtens
authored andcommitted
api: change <pk> parameter to <cover_id> for cover comments endpoint
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 <raxel@google.com> Reviewed-by: Stephen Finucane <stephen@that.guru> [dja: fixup to apply on top of fecf7c8 and 0ed2feb] Signed-off-by: Daniel Axtens <dja@axtens.net>
1 parent fe34ab2 commit 38959ba

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

patchwork/api/comment.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ class CoverCommentList(ListAPIView):
8383
search_fields = ('subject',)
8484
ordering_fields = ('id', 'subject', 'date', 'submitter')
8585
ordering = 'id'
86-
lookup_url_kwarg = 'pk'
86+
lookup_url_kwarg = 'cover_id'
8787

8888
def get_queryset(self):
89-
get_object_or_404(Cover, pk=self.kwargs['pk'])
89+
get_object_or_404(Cover, pk=self.kwargs['cover_id'])
9090

9191
return CoverComment.objects.filter(
92-
cover=self.kwargs['pk']
92+
cover=self.kwargs['cover_id']
9393
).select_related('submitter')
9494

9595

patchwork/api/cover.py

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

3838
def get_comments(self, cover):
3939
return self.context.get('request').build_absolute_uri(
40-
reverse('api-cover-comment-list', kwargs={'pk': cover.id}))
40+
reverse('api-cover-comment-list', kwargs={'cover_id': cover.id}))
4141

4242
def to_representation(self, instance):
4343
# NOTE(stephenfin): This is here to ensure our API looks the same even

patchwork/tests/api/test_comment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def api_url(cover, version=None):
2828
kwargs = {}
2929
if version:
3030
kwargs['version'] = version
31-
kwargs['pk'] = cover.id
31+
kwargs['cover_id'] = cover.id
3232

3333
return reverse('api-cover-comment-list', kwargs=kwargs)
3434

@@ -80,7 +80,7 @@ def test_list_version_1_0(self):
8080
def test_list_non_existent_cover(self):
8181
"""Ensure we get a 404 for a non-existent cover letter."""
8282
resp = self.client.get(
83-
reverse('api-cover-comment-list', kwargs={'pk': '99999'}))
83+
reverse('api-cover-comment-list', kwargs={'cover_id': '99999'}))
8484
self.assertEqual(status.HTTP_404_NOT_FOUND, resp.status_code)
8585

8686
def test_list_invalid_cover(self):

patchwork/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@
337337
name='api-patch-comment-list',
338338
),
339339
path(
340-
'covers/<int:pk>/comments/',
340+
'covers/<int:cover_id>/comments/',
341341
api_comment_views.CoverCommentList.as_view(),
342342
name='api-cover-comment-list',
343343
),

0 commit comments

Comments
 (0)