-
Notifications
You must be signed in to change notification settings - Fork 133
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
Check if XForm is a MergedXForm and merge field choices if it is(a MergedXForm) #2011
Conversation
70e9cad
to
1f46f1e
Compare
1f46f1e
to
64a7d1a
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've suggested a few changes but it generally looks good
if name: | ||
return get_field_from_field_name(name, xform) | ||
elif xpath: | ||
return get_field_from_field_xpath(xpath, xform) |
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.
if name: | |
return get_field_from_field_name(name, xform) | |
elif xpath: | |
return get_field_from_field_xpath(xpath, xform) | |
return get_field_from_field_xpath(name or xpath, xform) |
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'm not sure if this would work, because we need to call a different method when we have name
from when we have xpath
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.
Aah...cool, my bad. I thought it was the same function.
onadata/libs/utils/chart_tools.py
Outdated
try: | ||
merged_xform = MergedXForm.objects.get(pk=xform.pk) | ||
except MergedXForm.DoesNotExist: | ||
# this is not a MergedXForm | ||
pass |
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.
XForm has is_merged_dataset
property. We could re-write the above as
if xform.is_merged_dataset:
merged_xform = MergedXForm.objects.get(pk=xform.pk)
@@ -47,6 +74,59 @@ def setUp(self): | |||
os.path.dirname(__file__), '..', 'fixtures', 'forms', | |||
'tutorial', 'instances', '3.xml')) | |||
|
|||
def test_correct_data_for_charts(self): |
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.
Should we change the test name to something like test_correct_merged_dataset_data_for_charts
?
64a7d1a
to
5a7c892
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.
looks good to me. I'd like @DavisRayM to check this out as well
5a7c892
to
e028bdf
Compare
Steps taken to verify this change does what is intended
Closes #2013