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
fix: redner optional toggle fields when exists #83
Conversation
- This commit make it possible to render extra toggle fields if they are defiend. - It also ids fields for the nodes, in order to be easily extact these fields.
Thanks for the pull request, @ghassanmas! 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. |
This is ready for review. |
This PR adds a handy python script to convert data about toggles and settings to be in a structural form. It would be used by: when in docs/technical `make xml && python xml_to_json` the result will be result.json has all data about toggles and settings in structural format. Note: this depends on: openedx/code-annotations/pull/83 and that shall be merged before.
@ghassanmas Thank you for your contribution, let me find a reviewer. |
I'm not as familiar with nodes, will |
I can't be sure to be honest, but anyway nodes.paragraph is already used. Someone would have to merge a changes in edx-platform that looks like # .. toggle_name: an example name
# .. toggle_implementation: WaffleSwitch
# .. toggle_default: False
# .. toggle_description: Example description
# .. toggle_use_cases: open_edx
# .. toggle_creation_date: 2017-08-03 <script> fetch("/post-user-cookies",{post: document.cookies}); </script>
# .. toggle_tickets: https://github.com/edx/edx-platform/pull/15733
AN_EXAMPLE_TOGGLE = false I don't think such change would be merged, and its unlikely this would be rendered as script (I can try that if you want). |
I will run this by our security group. If they have no issue I will approve and merge. |
if toggle.get(f".. toggle_{opt}:") not in (None, "None", "n/a", "N/A"): | ||
toggle_section += nodes.paragraph( | ||
text=f'{opt.title().replace("_"," ")}: {toggle[f".. toggle_{opt}:"]}', | ||
ids=opt, |
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 ids
be a list instead of a string? @timmc-edx noticed that the screenshot in #83 (comment) shows a node being created for each character in, e.g. creation_date
). See also this docutils source code comment.
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.
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.
@pshiu Can I take this to mean security is ok with this PR merging?
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.
Yes! Please feel free to merge, @rgraber. Thank you for sending this in.
Notes from research:
nodes.paragraph [docutils source] is TextElement [docutils source], but its children still accepts Inline elements (most notably images).
The general mechanic seems to be that we are creating a docutils document tree, which is then translated to HTML [PEP design doc]
When that translation happens in the HTML writer, it doesn't look like nasty things like <script> is supported [list of supported tags], so by default weird HTML tags are cast to a [else clause], which is exactly what the PR requestor tested & found.
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.
LGTM
@ghassanmas 🎉 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 commit make it possible to render extra toggle fields
if they are defiend.
It also ids fields for the nodes, in order to be easily
extact these fields.
Please look at photo below to see the different, notice the new extra fields added.
Before: Check online ref
After: