Skip to content

Conversation

@pomegranited
Copy link
Contributor

@pomegranited pomegranited commented Jun 29, 2023

Description

Ensures that we always use the correct Taxonomy model subclass whenever returning or using Taxonomy instances.

Supporting information

Proposed way to address openedx/edx-platform#32518 (comment)

Testing instructions

Manual testing is possible but not very useful, since we don't yet have views for these models and APIs.

But you can check that the added tests cover the expected polymorphism behavior supported by this change, and that tests are still covering 100% of the openedx_tagging module.

Other information

Here we add a basic SystemTaxonomy class to help validate this change, but more functionality for system taxonomies will be added by a subsequent PR.

Author to do before merge:

* Adds dependency on django-model-utils (which is already a dependency
  of edx-platform)
* Updates api.get_taxonomies and adds api.get_taxonomy, which return the correct subclass of Taxonomy
* Adds a simple SystemTaxonomy base class to verify ^
* Updates tests to ensure correct classes are used, and no extra queries are required for this functionality
@openedx-webhooks
Copy link

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:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

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.

Comment on lines 439 to 444
# FIXME:
# * cache to prevent re-fetching the taxonomy
# * discourage people from using self.taxonomy
taxonomy = (
Taxonomy.objects.filter(id=self.taxonomy_id).select_subclasses().first()
)
Copy link
Contributor Author

@pomegranited pomegranited Jun 29, 2023

Choose a reason for hiding this comment

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

TODO What's the best way to handle this? We can cache the fetched taxonomy subclass using a getter property, but we'll need to rename the taxonomy field to _taxonomy.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 for this way

so we can ensure that the ObjectTag.taxonomy returned is of the correct subclass.
@pomegranited
Copy link
Contributor Author

Closed in favor of #62

@openedx-webhooks
Copy link

@pomegranited Even though your pull request wasn’t merged, please take a moment to answer a two question survey so we can improve your experience in the future.

@pomegranited pomegranited deleted the jill/taxonomy-inheritance-fix branch July 7, 2023 05:44
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

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants