Skip to content
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

Merged
merged 2 commits into from
Feb 9, 2021

Conversation

FrankApiyo
Copy link
Member

@FrankApiyo FrankApiyo commented Feb 5, 2021

Steps taken to verify this change does what is intended

  • Added a test case

Closes #2013

@FrankApiyo FrankApiyo changed the title [WIP]Check if XForm is a MergedXForm and merge field choices [WIP]Check if XForm is a MergedXForm and merge field choices if it is(a MergedXForm) Feb 5, 2021
@FrankApiyo FrankApiyo force-pushed the merge-merged-xform-field-choices branch 3 times, most recently from 70e9cad to 1f46f1e Compare February 8, 2021 12:56
@FrankApiyo FrankApiyo changed the title [WIP]Check if XForm is a MergedXForm and merge field choices if it is(a MergedXForm) Check if XForm is a MergedXForm and merge field choices if it is(a MergedXForm) Feb 8, 2021
@FrankApiyo FrankApiyo force-pushed the merge-merged-xform-field-choices branch from 1f46f1e to 64a7d1a Compare February 9, 2021 06:50
Copy link
Contributor

@ivermac ivermac left a 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

Comment on lines +443 to +446
if name:
return get_field_from_field_name(name, xform)
elif xpath:
return get_field_from_field_xpath(xpath, xform)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

Copy link
Member Author

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

Copy link
Contributor

@ivermac ivermac Feb 9, 2021

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.

Comment on lines 475 to 479
try:
merged_xform = MergedXForm.objects.get(pk=xform.pk)
except MergedXForm.DoesNotExist:
# this is not a MergedXForm
pass
Copy link
Contributor

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):
Copy link
Contributor

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?

@FrankApiyo FrankApiyo force-pushed the merge-merged-xform-field-choices branch from 64a7d1a to 5a7c892 Compare February 9, 2021 08:30
ivermac
ivermac previously approved these changes Feb 9, 2021
Copy link
Contributor

@ivermac ivermac left a 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

@DavisRayM DavisRayM merged commit d5c65f6 into master Feb 9, 2021
@DavisRayM DavisRayM deleted the merge-merged-xform-field-choices branch February 9, 2021 11:41
@DavisRayM DavisRayM mentioned this pull request Feb 23, 2021
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Charts endpoint does not return correct data for MergedXForms
3 participants