Skip to content

feat: add taxonomy_type to the taxonomy Get/List response - #39110

Open
ufedaseyeuconsultant wants to merge 1 commit into
openedx:masterfrom
ufedaseyeuconsultant:feat--618-update-get-endpoint-taxonomy-type
Open

ufedaseyeuconsultant wants to merge 1 commit into
openedx:masterfrom
ufedaseyeuconsultant:feat--618-update-get-endpoint-taxonomy-type

Conversation

@ufedaseyeuconsultant

Copy link
Copy Markdown

Description

TaxonomyOrgSerializer now reports a read-only taxonomy_type on the taxonomy Get/List
response: "competency" if the taxonomy has a related CompetencyTaxonomy row, "tags"
otherwise. Implements the acceptance criteria from #618.

Changes

  • TaxonomyOrgSerializer.to_representation(): overridden to inject taxonomy_type into the
    output after super().to_representation(), computed via
    openedx_learning.api.is_competency_taxonomy(). Not a new declared field: TaxonomySerializer
    already declares taxonomy_type as write-only (create-time input, consumed by
    perform_create()), so a same-named SerializerMethodField would have silently replaced it
    and 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(): adds select_competency_taxonomies() to the existing
    queryset chain, so the per-row is_competency_taxonomy() check on list costs no extra query.
  • Neither openedx_tagging's Taxonomy model nor its base TaxonomySerializer change, per
    ADR 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_type correct and none null. One scenario deviates from the ticket text:
it asks for a "system-defined taxonomy" (system_defined=true) case, but system_defined isn't
a field on TaxonomySerializer at all anymore (removed well before this PR) — substituted a
read_only taxonomy instead, asserting taxonomy_type == "tags" and read_only is True.
Re-ran the existing test_list_taxonomy_query_count (assertNumQueries) unchanged: same counts
with and without this change, confirming select_competency_taxonomies()'s join adds no query.

Manual testing instructions

No local openedx-core mount needed: is_competency_taxonomy() / select_competency_taxonomies()
already shipped in the pinned openedx-core==1.4.0 (same release, same PR,
openedx-core#803, as create_competency_taxonomy()). A standard tutor images build openedx-dev
against this branch is enough.

  1. Restart Studio on this branch:

    tutor dev restart lms cms
    
  2. 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):

    COOKIES=/tmp/lms_cookies.txt; rm -f "$COOKIES"
    curl -s -c "$COOKIES" "http://local.openedx.io:8000/login" -o /dev/null
    CSRFTOKEN=$(grep csrftoken "$COOKIES" | awk '{print $NF}')
    curl -s -b "$COOKIES" -c "$COOKIES" -H "X-CSRFToken: $CSRFTOKEN" -H "Referer: http://local.openedx.io:8000/login" --data-urlencode "email=test@test.com" --data-urlencode "password=test" "http://local.openedx.io:8000/api/user/v1/account/login_session/" -o /dev/null -w "login status: %{http_code}\n"
    AUTH_HEADER="Authorization: JWT $(grep "edx-jwt-cookie-header-payload" "$COOKIES" | awk '{print $NF}').$(grep "edx-jwt-cookie-signature" "$COOKIES" | awk '{print $NF}')"
    CMS_URL="http://studio.local.openedx.io:8001"
  3. Create one taxonomy of each type to check against:

    curl -s -H "$AUTH_HEADER" -H "Content-Type: application/json" -X POST "$CMS_URL/api/content_tagging/v1/taxonomies/" -d '{"name": "Test Competency", "description": "test", "taxonomy_type": "competency"}'
    curl -s -H "$AUTH_HEADER" -H "Content-Type: application/json" -X POST "$CMS_URL/api/content_tagging/v1/taxonomies/" -d '{"name": "Test Tags", "description": "test", "taxonomy_type": "tags"}'
  4. Get each by id — expect "taxonomy_type": "competency" and "taxonomy_type": "tags"
    respectively:

    curl -s -H "$AUTH_HEADER" "$CMS_URL/api/content_tagging/v1/taxonomies/<competency_id>/"
    curl -s -H "$AUTH_HEADER" "$CMS_URL/api/content_tagging/v1/taxonomies/<tags_id>/"
  5. List — expect both entries present, each with the correct taxonomy_type, neither null:

    curl -s -H "$AUTH_HEADER" "$CMS_URL/api/content_tagging/v1/taxonomies/"
  6. Confirm in MySQL that a CompetencyTaxonomy row exists for the competency taxonomy's id and
    not for the tags one.

Related to: ADR 0013 (openedx-core)

🤖 Generated with help of Claude Code

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>
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Sep 16, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @ufedaseyeuconsultant!

This repository is currently maintained by @openedx/wg-maintenance-openedx-platform-oncall.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where 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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@mgwozdz-unicon mgwozdz-unicon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@mphilbrick211 mphilbrick211 moved this from Needs Triage to In Eng Review in Contributions Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: In Eng Review

Development

Successfully merging this pull request may close these issues.

4 participants