Skip to content

Commit

Permalink
fix: Use external participant ID for api queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico-AP committed Aug 28, 2023
1 parent 05e3443 commit f5dc191
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ddm/tests/test_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def test_donations_api_get_with_valid_api_credentials(self):
'donation blueprint': [{'data': ['donated_data', 'donated_data']}]
}
response = client.get(
reverse('donations-api', args=[self.project_base.pk]), {'participants': str(self.participant.pk)})
reverse('donations-api', args=[self.project_base.pk]), {'participants': str(self.participant.external_id)})
self.assertEqual(response.status_code, 200)
self.assertEqual(response.data, expected_response)

Expand Down Expand Up @@ -246,7 +246,7 @@ def test_responses_api_get_with_valid_api_credentials(self):

expected_response = [{'open': 'response_data'}]
response = client.get(
reverse('responses-api', args=[self.project_base.pk]), {'participants': str(self.participant.pk)})
reverse('responses-api', args=[self.project_base.pk]), {'participants': str(self.participant.external_id)})
self.assertEqual(response.status_code, 200)
self.assertEqual(response.data, expected_response)

Expand Down
4 changes: 2 additions & 2 deletions ddm/views/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def get_donations(self, blueprint):
participants = self.request.query_params.get('participants')
if participants is not None:
return blueprint.datadonation_set.filter(
participant__in=participants.split(','))
participant__external_id__in=participants.split(','))
else:
return blueprint.datadonation_set.all()

Expand Down Expand Up @@ -495,7 +495,7 @@ def get_responses(self, project):
participants = self.request.query_params.get('participants')
if participants is not None:
return QuestionnaireResponse.objects.filter(
project=project, participant__in=participants.split(','))
project=project, participant__external_id__in=participants.split(','))
else:
return QuestionnaireResponse.objects.filter(project=project)

Expand Down

0 comments on commit f5dc191

Please sign in to comment.