Skip to content

Commit 6bdab16

Browse files
kdmccormickclaude
andauthored
fix: Migrate LanguagesTaxnomy._taxonomy_class to reflect refactoring (#489)
Fixes an error along the lines of: Unable to import taxonomy_class for -1: openedx_tagging.core.tagging.models.system_defined.LanguageTaxonomy This was missed in: #470 We had updated migration 0012 to initialize LanguagesTaxonomy with the post-refactoring _taxonomy_class, but didn't add a new data migration to fix the classpath. Migration 0019 now fixes that. This commit also reverts our change to 0012 for the sake of historical continuity (but it doesn't really matter either way since 0019 will overwrite the _taxonomy_class). Bumps patch version -> 0.34.2 Co-authored-by: Claude Code <noreply@anthropic.com>
1 parent 603762d commit 6bdab16

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

src/openedx_core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
"""
77

88
# The version for the entire repository
9-
__version__ = "0.34.1"
9+
__version__ = "0.34.2"

src/openedx_tagging/migrations/0012_language_taxonomy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def create_language_taxonomy(apps, schema_editor):
1818
"allow_multiple": False,
1919
"allow_free_text": False,
2020
"visible_to_authors": True,
21-
"_taxonomy_class": "openedx_tagging.models.system_defined.LanguageTaxonomy",
21+
"_taxonomy_class": "openedx_tagging.core.tagging.models.system_defined.LanguageTaxonomy",
2222
})
2323

2424
# But delete any unused tags created by the old fixture:
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""
2+
Data migration to update the _taxonomy_class on the Languages system taxonomy
3+
to reflect the new module path after the package rename.
4+
5+
Old: openedx_tagging.core.tagging.models.system_defined.LanguageTaxonomy
6+
New: openedx_tagging.models.system_defined.LanguageTaxonomy
7+
"""
8+
9+
from django.db import migrations
10+
11+
OLD_CLASS = "openedx_tagging.core.tagging.models.system_defined.LanguageTaxonomy"
12+
NEW_CLASS = "openedx_tagging.models.system_defined.LanguageTaxonomy"
13+
14+
15+
def update_language_taxonomy_class(apps, schema_editor):
16+
Taxonomy = apps.get_model("oel_tagging", "Taxonomy")
17+
Taxonomy.objects.filter(_taxonomy_class=OLD_CLASS).update(_taxonomy_class=NEW_CLASS)
18+
19+
20+
def revert_language_taxonomy_class(apps, schema_editor):
21+
Taxonomy = apps.get_model("oel_tagging", "Taxonomy")
22+
Taxonomy.objects.filter(_taxonomy_class=NEW_CLASS).update(_taxonomy_class=OLD_CLASS)
23+
24+
25+
class Migration(migrations.Migration):
26+
27+
dependencies = [
28+
("oel_tagging", "0018_objecttag_is_copied"),
29+
]
30+
31+
operations = [
32+
migrations.RunPython(update_language_taxonomy_class, revert_language_taxonomy_class),
33+
]

0 commit comments

Comments
 (0)