search_fields = ('subject',)
ordering_fields = ('id', 'subject', 'date', 'submitter')
ordering = 'id'
- lookup_url_kwarg = 'pk'
+ lookup_url_kwarg = 'patch_id'
def get_queryset(self):
- if not Patch.objects.filter(pk=self.kwargs['pk']).exists():
+ if not Patch.objects.filter(id=self.kwargs['patch_id']).exists():
raise Http404
return PatchComment.objects.filter(
- patch=self.kwargs['pk']
+ patch=self.kwargs['patch_id']
).select_related('submitter')
def get_comments(self, patch):
return self.context.get('request').build_absolute_uri(
- reverse('api-patch-comment-list', kwargs={'pk': patch.id}))
+ reverse('api-patch-comment-list', kwargs={'patch_id': patch.id}))
def get_check(self, instance):
return instance.combined_check_state
kwargs = {}
if version:
kwargs['version'] = version
- kwargs['pk'] = patch.id
+ kwargs['patch_id'] = patch.id
return reverse('api-patch-comment-list', kwargs=kwargs)
def test_list_invalid_patch(self):
"""Ensure we get a 404 for a non-existent patch."""
resp = self.client.get(
- reverse('api-patch-comment-list', kwargs={'pk': '99999'}))
+ reverse('api-patch-comment-list', kwargs={'patch_id': '99999'}))
self.assertEqual(status.HTTP_404_NOT_FOUND, resp.status_code)
api_1_1_patterns = [
path(
- 'patches/<pk>/comments/',
+ 'patches/<patch_id>/comments/',
api_comment_views.PatchCommentList.as_view(),
name='api-patch-comment-list',
),