-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exposes submissions url to enketo #1526
Conversation
e4dbef2
to
2abc635
Compare
onadata/libs/utils/viewer_tools.py
Outdated
@@ -367,3 +366,27 @@ def get_enketo_preview_url(request, username, id_string, xform_pk=None): | |||
raise EnketoError(response['message']) | |||
|
|||
return False | |||
|
|||
|
|||
def get_submission_url(request, username, id_string, xform_pk=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function is not named properly. It is supposed to return the Enketo URL for a single submit survey, probably get_single_submit_url()
would be more appropriate. The function docs should also reflect that.
onadata/libs/utils/viewer_tools.py
Outdated
|
||
def get_submission_url(request, username, id_string, xform_pk=None): | ||
"""Return submission url of the submission instance.""" | ||
enketo_url = settings.ENKETO_URL + "/api/v2/survey/single/once" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we assign "/api/v2/survey/single/once"
to a static variable or better yet a settings variable, see examples above in the enketo_url()
function.
enketo_url = settings.ENKETO_URL + getattr(settings, 'ENKETO_SINGLE_SUBMIT_PATH', "/api/v2/survey/single/once")
onadata/libs/utils/viewer_tools.py
Outdated
data = response.json() | ||
submission_url = data['single_url'] | ||
return submission_url | ||
elif response.status_code == 400: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are raising the same exception with the same error message we probably should only have only the else clause. Check enketo_url()
function, could be something that might need to be refactored into a function that can be used by both.
6287c41
to
bc70f2a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see we do not have an issue for this pull request. From what I can tell in the message, we are supposed to be adding an API endpoint that will allow us to create the single submit Enketo URL. This PR only includes the functionality to make an API request to Enketo but does not expose the feature in the API. Can we:
- Expose the functionality on an API endpoint
- Update API docs on making use of this functionality.
requirements/base.pip
Outdated
@@ -110,6 +110,7 @@ pyxform==0.12.2 | |||
raven==6.9.0 | |||
recaptcha-client==1.0.6 | |||
requests==2.20.1 # via datapackage, django-oauth-toolkit, httmock, sphinx, tableschema, tabulator | |||
requests-mock==1.5.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use pip-tools to generate the pip requirements file. As such we also need to add the required modules into the setup.py
under install_requires
otherwise this package will not be included next time we regenerate the pip files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noted. will include the packages there as well.
|
||
with self.assertRaises(EnketoError): | ||
get_single_submit_url( | ||
request, username='Milly', id_string="tag_team", xform_pk=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The request is not being mocked as was done in test_get_single_submit_url()
, what EnketoError exception is being tested exactly? Can we apply a mock to the request object for very specific EnketoError exception? We could also check the exception message.
7ab7184
to
402b4a3
Compare
b93828a
to
3c110a8
Compare
941511c
to
a758205
Compare
4e9f3b6
to
7ba2cdf
Compare
f16b2da
to
cf95655
Compare
6b91f9e
to
de8f115
Compare
de8f115
to
12eb9b3
Compare
c73721b
to
391b09f
Compare
391b09f
to
9d18048
Compare
9d18048
to
391b09f
Compare
0b7559b
to
73c46b1
Compare
Signed-off-by: Lincoln Simba <[email protected]>
Signed-off-by: Lincoln Simba <[email protected]>
Signed-off-by: Lincoln Simba <[email protected]>
Signed-off-by: Lincoln Simba <[email protected]>
Signed-off-by: Lincoln Simba <[email protected]>
73c46b1
to
ec457c2
Compare
This PR contains the functionality to expose Enketo's single submission url.