-
Notifications
You must be signed in to change notification settings - Fork 11
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
Taxonomy import templates [FC-0036] #89
Conversation
Thanks for the pull request, @pomegranited! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
7c82a49
to
d302a98
Compare
This allows us to add comments to our template import files, but more importantly, allows users to import tags from an external source which may have extra data we don't care about.
These files are annotated with a "comments" field, explaining how taxonomy tag imports work. The tests verify that these files are imported without error, and that they create the expected tags.
fe72564
to
1476d44
Compare
Hi @pomegranited! Good work here! I really like how you always came up with meaningful sample data, instead of "tag 1", "tag 2", etc.. 😃 I made a comment about our parser that I think we should be aware, but is not related to this PR.
|
for opt_field in cls.optional_fields: | ||
if opt_field in tag and not tag.get(opt_field): | ||
tag[opt_field] = None | ||
tag_data[opt_field] = tag.get(opt_field) or 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.
If tag_data[opt_field]
is falsy (i.e. 0), we are overriding with None
.
I don't think this is a problem because our optional_fields
only have the external_id, but we may have some issues using this parser for other 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.
@rpenido Yeah, I was preserving the previous behavior with that change, since the CSV parser will send us empty strings for parent_id
, when what we really want is None
.
I think that if we ever need the parser to do something different, then there will be a clear use case, and the code and tests can be modified then.
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.
Very nice work!
@pomegranited 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
This PR adds CSV and JSON templates which demonstrate the format for Taxonomy Administrators to use when importing the tags to a taxonomy.
The templates use an ignored "comments" fields to explain how to use the template inline with the example. To support this, I altered the taxonomy import code to ignore any unexpected fields. Ignoring unexpected fields will also make it easier for users to import files provided by external taxonomy suppliers, as these are likely to contain more fields than we need.
Also adds tests to ensure that the templates import without error.
Closes openedx/modular-learning#137
Private-ref: FAL-3520
Testing instructions
python manage.py runserver
http://127.0.0.1:8000/tagging/rest_api/v1/import/template.csv
http://127.0.0.1:8000/tagging/rest_api/v1/import/template.json
TO DO BEFORE MERGE