Skip to content

Commit

Permalink
Modify Enketo submission and formList urls
Browse files Browse the repository at this point in the history
Modify Enketo submission and formList urls by changing the name of the
"form_pk" arguement to "xform_pk"
  • Loading branch information
DavisRayM committed Apr 17, 2020
1 parent 4a09316 commit 35218f2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
6 changes: 3 additions & 3 deletions onadata/apps/api/tests/viewsets/test_xform_list_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ def test_retrieve_form_using_pk(self):
request = self.factory.get(
f'/enketo/{self.xform.pk}/formList')
response = self.view(
request, form_pk=self.xform.pk)
request, xform_pk=self.xform.pk)
self.assertEqual(response.status_code, 401)

# Set require auth to false for form owner
Expand All @@ -1030,7 +1030,7 @@ def test_retrieve_form_using_pk(self):
f'/enketo/{self.xform.pk}/formList')
request.META.update(auth(request.META, response))
response = self.view(
request, form_pk=self.xform.pk)
request, xform_pk=self.xform.pk)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data), 1)
self.assertEqual(
Expand All @@ -1041,7 +1041,7 @@ def test_retrieve_form_using_pk(self):
request = self.factory.get(
f'/enketo/{self.xform.pk}/formList')
response = self.view(
request, form_pk=self.xform.pk)
request, xform_pk=self.xform.pk)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data), 1)
self.assertEqual(
Expand Down
2 changes: 1 addition & 1 deletion onadata/apps/api/viewsets/xform_list_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def get_renderers(self):

def filter_queryset(self, queryset):
username = self.kwargs.get('username')
form_pk = self.kwargs.get('form_pk')
form_pk = self.kwargs.get('xform_pk')
if (not username and not form_pk) and \
self.request.user.is_anonymous:
# raises a permission denied exception, forces authentication
Expand Down
4 changes: 2 additions & 2 deletions onadata/apps/main/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
re_path(r'^(?P<username>\w+)/formList$',
XFormListViewSet.as_view({'get': 'list', 'head': 'list'}),
name='form-list'),
re_path(r'^enketo/(?P<form_pk>\w+)/formList$',
re_path(r'^enketo/(?P<xform_pk>\w+)/formList$',
XFormListViewSet.as_view({'get': 'list', 'head': 'list'}),
name='form-list'),
re_path(r'^(?P<username>\w+)/(?P<xform_pk>\d+)/formList$',
Expand Down Expand Up @@ -258,7 +258,7 @@
re_path(r'^(?P<username>\w+)/submission$',
XFormSubmissionViewSet.as_view({'post': 'create', 'head': 'create'}),
name='submissions'),
re_path(r'^enketo/(?P<form_pk>\w+)/submission$',
re_path(r'^enketo/(?P<xform_pk>\w+)/submission$',
XFormSubmissionViewSet.as_view({'post': 'create', 'head': 'create'}),
name='submissions'),
re_path(r'^(?P<username>\w+)/(?P<xform_pk>\d+)/submission$',
Expand Down
4 changes: 0 additions & 4 deletions onadata/libs/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ def filter_queryset(self, request, queryset, view):
view.lookup_field, view.kwargs.get('xform_pk'))
lookup_field = view.lookup_field

if view.kwargs.get('form_pk'):
form_id = view.kwargs.get('form_pk')
lookup_field = 'pk'

queryset = queryset.filter(deleted_at=None)
if request.user.is_anonymous:
return queryset
Expand Down

0 comments on commit 35218f2

Please sign in to comment.