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

Passing filename as the default form id parameter. #389

Merged
merged 2 commits into from
Nov 5, 2019

Conversation

nribeka
Copy link
Contributor

@nribeka nribeka commented Oct 21, 2019

Fix #388.

Introduce a new parameter for the workbook_to_json by passing the xls filename as the default value for the form_id. This will be replaced with value from the settings tab if supplied.

@codecov-io
Copy link

codecov-io commented Oct 21, 2019

Codecov Report

Merging #389 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #389      +/-   ##
==========================================
+ Coverage   82.42%   82.42%   +<.01%     
==========================================
  Files          23       23              
  Lines        3260     3261       +1     
  Branches      763      763              
==========================================
+ Hits         2687     2688       +1     
+ Misses        433      432       -1     
- Partials      140      141       +1
Impacted Files Coverage Δ
pyxform/xls2json.py 78.07% <100%> (+0.19%) ⬆️
pyxform/xform2json.py 79.66% <0%> (-0.21%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7fc5e90...ab0e876. Read the comment docs.

@nribeka nribeka marked this pull request as ready for review October 22, 2019 12:27
Copy link
Contributor

@lognaturel lognaturel left a comment

Choose a reason for hiding this comment

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

Apologies for not noticing this problem in the pyxform/tests/test_expected_output/survey_no_name.xml test output originally! I think some clearer naming would help make it more explicit what the relationship between the existing form_name parameter and the new parameter is. Previously I didn't realize that form_name was being used for the root node, the form title and the form ID.

workbook_dict, form_name=None, default_language="default", warnings=None
workbook_dict,
form_name=None,
form_id=None,
Copy link
Contributor

Choose a reason for hiding this comment

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

How about calling this new parameter fallback_form_name so it's clear that it's a companion to form_name that's only used as a fallback?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to fallback_form_name. I think it makes sense to call it that way.

@@ -1316,7 +1320,10 @@ def parse_file_to_json(
if warnings is None:
warnings = []
workbook_dict = parse_file_to_workbook_dict(path, file_object)
return workbook_to_json(workbook_dict, default_name, default_language, warnings)
default_form_id = unicode(get_filename(path))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think calling this local value fallback_form_name would also be more helpful.

@lognaturel lognaturel merged commit ce15c5d into XLSForm:master Nov 5, 2019
DavisRayM added a commit to onaio/onadata that referenced this pull request Feb 27, 2020
Modify the 'test_spaced_xlsform' to ensure that a file with an invalid
filename is caught and handled. More Info:
XLSForm/pyxform#389
DavisRayM added a commit to onaio/onadata that referenced this pull request Feb 27, 2020
Modify the 'test_spaced_xlsform' to ensure that a file with an invalid
filename is caught and handled. More Info:
XLSForm/pyxform#389
DavisRayM added a commit to onaio/onadata that referenced this pull request Feb 27, 2020
Modify the 'test_spaced_xlsform' to ensure that a file with an invalid
filename is caught and handled. More Info:
XLSForm/pyxform#389
DavisRayM added a commit to onaio/onadata that referenced this pull request Mar 2, 2020
Modify the 'test_spaced_xlsform' to ensure that a file with an invalid
filename is caught and handled. More Info:
XLSForm/pyxform#389
DavisRayM added a commit to onaio/onadata that referenced this pull request Mar 2, 2020
Update the error raised when an id_string is invalid. PyXForm now
utilizes the filename as the form_id if it's not explicitly set in the
settings sheet. More Info: XLSForm/pyxform#389
DavisRayM added a commit to onaio/onadata that referenced this pull request Mar 2, 2020
Update the error raised when an id_string is invalid. PyXForm now
utilizes the filename as the form_id if it's not explicitly set in the
settings sheet. More Info: XLSForm/pyxform#389
DavisRayM added a commit to onaio/onadata that referenced this pull request Mar 3, 2020
Update the error raised when an id_string is invalid. PyXForm now
utilizes the filename as the form_id if it's not explicitly set in the
settings sheet. More Info: XLSForm/pyxform#389
DavisRayM added a commit to onaio/onadata that referenced this pull request Mar 3, 2020
Update the error raised when an id_string is invalid. PyXForm now
utilizes the filename as the form_id if it's not explicitly set in the
settings sheet. More Info: XLSForm/pyxform#389
DavisRayM added a commit to onaio/onadata that referenced this pull request Mar 13, 2020
Update the error raised when an id_string is invalid. PyXForm now
utilizes the filename as the form_id if it's not explicitly set in the
settings sheet. More Info: XLSForm/pyxform#389
DavisRayM added a commit to onaio/onadata that referenced this pull request Mar 27, 2020
Update the error raised when an id_string is invalid. PyXForm now
utilizes the filename as the form_id if it's not explicitly set in the
settings sheet. More Info: XLSForm/pyxform#389
DavisRayM added a commit to onaio/onadata that referenced this pull request Mar 27, 2020
Update the error raised when an id_string is invalid. PyXForm now
utilizes the filename as the form_id if it's not explicitly set in the
settings sheet. More Info: XLSForm/pyxform#389
DavisRayM added a commit to onaio/onadata that referenced this pull request Mar 27, 2020
Update the error raised when an id_string is invalid. PyXForm now
utilizes the filename as the form_id if it's not explicitly set in the
settings sheet. More Info: XLSForm/pyxform#389
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.

Form title and form_id should not default to data
3 participants