-
Notifications
You must be signed in to change notification settings - Fork 81
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
Adds support for accuracyThreshold #1703
Conversation
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.
This is a solid piece of work! I only have one inline code comment. Aside from that I have the following questions:
- Does pyxform validate that
accuracyThreshold
is only present on geo fields? I don't think it makes sense for us to reject XLSForms that have invalid values foraccuracyThreshold
on non-geo fields. If pyxform doesn't support this validation, should we build it ourselves? - For the manual test cases, I suppose we should add test cases for attempting to upload XLSForms with valid and various invalid values (like
-1.5
,0
, andSTRING
).
@@ -45,6 +63,10 @@ def test_validate_id_string_contains_whitespace(self): | |||
"'id_string' cannot be blank or contain whitespace.") | |||
|
|||
|
|||
def positive(val): | |||
return val > 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 function name doesn't seem to match the condition. Should this be val > 0
? (But this is admittedly inconsequential in the grand scheme of things.)
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.
Changed that.
pyxform does not check if
Sounds about right. |
@seav I added code to make sure |
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.
Just a couple of spelling errors and this should be good to go from my end. :)
assert model.gps_accuracy == 1.5 | ||
|
||
def test_create_from_dict_ingnore_accuracy_threshold(self): | ||
"""For non-geomtrey fields accuracy should be ignored""" |
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.
[MINOR] "geomtrey" should be ""geometry".
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.
Fixed
@@ -21,6 +21,12 @@ def test_wrong_type(self): | |||
assert validators.validate_accuracy('Something') is False | |||
|
|||
|
|||
class GpsRelevvantTest(TestCase): |
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.
[MINOR] Relevvant
should be Relevant
.
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.
Fixed
(Weird. I check items on the review checklist but they aren't persistent...) |
It seems to only work for bugs for some reason... |
Sorry about the delay, will attempt to get to this over the weekend. |
return json.get('type') in XFORM_GEOM_FIELDS | ||
|
||
|
||
def validate_id_string(json): |
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.
nitpick: json
doesn't feel like an appropriate name for this field as JSON is a str
and these are obviously dict
instances. Maybe just data
? 🤷♂️
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 that this is done elsewhere. Maybe it's our convention and we should leave as is.
28a97ba
to
4d9fd1e
Compare
Proposed changes in this pull request
Implements #597: Adds support for XLSForm's
accuracyThreshold
to set the minimum GPS accuracy required when collecting coordinates in GeoODK.questionnaires.validators.validate_accuracy
, which checks if a given value is a positive float. This is used in various places to validate input foraccuracyThreshold
.questionnaires.models.Question.TYPE_CHOICES
intoquestionnaires.choices.QUESTION_TYPES
to resolve a circular import betweenmodels
andvalidators
gps_accuracy
toquestionnaires.models.Question
.questionnaires.managers.QuestionManager.create_from_dict
so it reads and storesaccuracyThreshold
from XLSForms.xforms.renderers.XFormRenderer
soaccuracyThreshold
is added to rendered XForms, which are used by GeoODK.gps_accuracy
toquestionnaires.serializers.QuestionSerializer
so the value is read and written via the JSON API.questionnaires.validators.QUESTION_SCHEMA
sogps_accuracy
is validated usingquestionnaires.validators.validate_accuracy
.questionnaires.validators.validate_schema
is also extended, so fields can be validated using validation functions.When should this PR be merged
Should go into the sprint 20 release.
Risks
None.
Follow-up actions
The rendering of
accuracyThreshold
into XForms needs to be verified using GeoODK.Checklist (for reviewing)
General
migration
label if a new migration is added.Functionality
Code
Tests
Security
Documentation