feat: add taxonomy_type to the taxonomy Get/List response - #39110
ufedaseyeuconsultant wants to merge 1 commit into
Conversation
TaxonomyOrgSerializer now reports a read-only taxonomy_type
("tags"/"competency") on GET, computed via openedx_learning.api's
is_competency_taxonomy(), so Studio can badge Competency Taxonomies
and gate the Competency Management page. TaxonomyOrgView.get_queryset()
selects the related CompetencyTaxonomy row so this costs no extra
query per row.
Per ADR 0013 (openedx-core), computed instead of naming the
CompetencyTaxonomy relation directly.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Thanks for the pull request, @ufedaseyeuconsultant! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
mgwozdz-unicon
left a comment
There was a problem hiding this comment.
This looks good! One thing: Please update the links in your description for "#618" to point to openedx/openedx-core#618. Since this is the openedx-platform repo, it defaults "#618" to point at PR #618 for this repo instead of Github Issue #618 from the repo that houses our CBE Github Project.
Description
TaxonomyOrgSerializernow reports a read-onlytaxonomy_typeon the taxonomy Get/Listresponse:
"competency"if the taxonomy has a relatedCompetencyTaxonomyrow,"tags"otherwise. Implements the acceptance criteria from #618.
Changes
TaxonomyOrgSerializer.to_representation(): overridden to injecttaxonomy_typeinto theoutput after
super().to_representation(), computed viaopenedx_learning.api.is_competency_taxonomy(). Not a new declared field:TaxonomySerializeralready declares
taxonomy_typeas write-only (create-time input, consumed byperform_create()), so a same-namedSerializerMethodFieldwould have silently replaced itand broken taxonomy creation. DRF excludes write-only fields from output entirely, so this
override adds the key rather than colliding with one.
TaxonomyOrgView.get_queryset(): addsselect_competency_taxonomies()to the existingqueryset chain, so the per-row
is_competency_taxonomy()check on list costs no extra query.openedx_tagging'sTaxonomymodel nor its baseTaxonomySerializerchange, perADR 0013 (openedx-core).
Tests
Four test methods, one per #618's Given/When/Then scenario: a plain taxonomy's detail response
→
"tags", a competency taxonomy's detail response →"competency", a list of mixed types →each entry's
taxonomy_typecorrect and none null. One scenario deviates from the ticket text:it asks for a "system-defined taxonomy" (
system_defined=true) case, butsystem_definedisn'ta field on
TaxonomySerializerat all anymore (removed well before this PR) — substituted aread_onlytaxonomy instead, assertingtaxonomy_type == "tags"andread_only is True.Re-ran the existing
test_list_taxonomy_query_count(assertNumQueries) unchanged: same countswith and without this change, confirming
select_competency_taxonomies()'s join adds no query.Manual testing instructions
No local
openedx-coremount needed:is_competency_taxonomy()/select_competency_taxonomies()already shipped in the pinned
openedx-core==1.4.0(same release, same PR,openedx-core#803, ascreate_competency_taxonomy()). A standardtutor images build openedx-devagainst this branch is enough.
Restart Studio on this branch:
Auth script (captures cookies/CSRF/JWT so you don't have to copy requests from devtools each
time; non-default cases can also be driven from the UI):
Create one taxonomy of each type to check against:
Get each by id — expect
"taxonomy_type": "competency"and"taxonomy_type": "tags"respectively:
List — expect both entries present, each with the correct
taxonomy_type, neither null:Confirm in MySQL that a
CompetencyTaxonomyrow exists for the competency taxonomy's id andnot for the tags one.
Related to: ADR 0013 (openedx-core)
🤖 Generated with help of Claude Code