-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: features to enable import/export courses (#172)
- Rename taxonomy._name to taxonomy._export_id - Refactor all code about taxonomy._name - Update resync object tags to update the taxonomy from _export_id - Update tag_object to allow create object_id with invalid tags and taxonomies - Add additional reserved characters used for input/output cases
- Loading branch information
Showing
11 changed files
with
405 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
""" | ||
Open edX Learning ("Learning Core"). | ||
""" | ||
__version__ = "0.7.0" | ||
__version__ = "0.8.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
openedx_tagging/core/tagging/migrations/0016_object_tag_export_id.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Generated by Django 3.2.22 on 2024-03-22 19:47 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
import openedx_learning.lib.fields | ||
|
||
|
||
def migrate_export_id(apps, schema_editor): | ||
ObjectTag = apps.get_model("oel_tagging", "ObjectTag") | ||
for object_tag in ObjectTag.objects.all(): | ||
if object_tag.taxonomy: | ||
object_tag.export_id = object_tag.taxonomy.export_id | ||
object_tag.save(update_fields=["_export_id"]) | ||
|
||
|
||
def reverse_export_id(apps, schema_editor): | ||
pass | ||
|
||
|
||
def migrate_language_export_id(apps, schema_editor): | ||
Taxonomy = apps.get_model("oel_tagging", "Taxonomy") | ||
language_taxonomy = Taxonomy.objects.get(id=-1) | ||
language_taxonomy.export_id = 'languages-v1' | ||
language_taxonomy.save(update_fields=["export_id"]) | ||
|
||
|
||
def reverse_language_export_id(apps, schema_editor): | ||
""" | ||
Return to old export_id | ||
""" | ||
Taxonomy = apps.get_model("oel_tagging", "Taxonomy") | ||
language_taxonomy = Taxonomy.objects.get(id=-1) | ||
language_taxonomy.export_id = '-1-languages' | ||
language_taxonomy.save(update_fields=["export_id"]) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('oel_tagging', '0015_taxonomy_export_id'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name='objecttag', | ||
old_name='_name', | ||
new_name='_export_id', | ||
), | ||
migrations.RunPython(migrate_export_id, reverse_export_id), | ||
migrations.AlterField( | ||
model_name='objecttag', | ||
name='taxonomy', | ||
field=models.ForeignKey(blank=True, default=None, help_text="Taxonomy that this object tag belongs to. Used for validating the tag and provides the tag's 'name' if set.", null=True, on_delete=django.db.models.deletion.SET_NULL, to='oel_tagging.taxonomy'), | ||
), | ||
migrations.AlterField( | ||
model_name='objecttag', | ||
name='_export_id', | ||
field=openedx_learning.lib.fields.MultiCollationCharField(db_collations={'mysql': 'utf8mb4_unicode_ci', 'sqlite': 'NOCASE'}, help_text='User-facing label used for this tag, stored in case taxonomy is (or becomes) null. If the taxonomy field is set, then taxonomy.export_id takes precedence over this field.', max_length=255), | ||
), | ||
migrations.RunPython(migrate_language_export_id, reverse_language_export_id), | ||
] |
Oops, something went wrong.