-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add export_id field on Taxonomy #145
Merged
pomegranited
merged 9 commits into
openedx:main
from
open-craft:chris/FAL-3620-export-id-on-taxonomies
Feb 1, 2024
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e3ef5a5
feat: Add export_id field on Taxonomy
ChrisChV 07988a9
Merge branch 'main' into chris/FAL-3620-export-id-on-taxonomies
ChrisChV e0062ba
chore: Bump version
ChrisChV 2bece8f
chore: Update migration
ChrisChV db64b9f
style: Replace '.' to '_' in migration
ChrisChV b341e9b
feat: Adding slugify in migration
ChrisChV 4b69568
refactor: Auto generate export_id on create_taxonomy API if the param…
ChrisChV 956ff96
style: Nit on tests
ChrisChV f53025c
style: Nits
ChrisChV File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.4.4" | ||
__version__ = "0.5.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
37 changes: 37 additions & 0 deletions
37
openedx_tagging/core/tagging/migrations/0015_taxonomy_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,37 @@ | ||
# Generated by Django 3.2.22 on 2024-01-25 14:20 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
def migrate_export_id(apps, schema_editor): | ||
Taxonomy = apps.get_model("oel_tagging", "Taxonomy") | ||
for taxonomy in Taxonomy.objects.all(): | ||
# Adds the id of the taxonomy to avoid duplicates | ||
taxonomy.export_id = f"{taxonomy.id}_{taxonomy.name.lower().replace(' ', '.')}" | ||
taxonomy.save(update_fields=["export_id"]) | ||
|
||
def reverse(app, schema_editor): | ||
pass | ||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('oel_tagging', '0014_minor_fixes'), | ||
] | ||
|
||
operations = [ | ||
# Create the field allowing null | ||
migrations.AddField( | ||
model_name='taxonomy', | ||
name='export_id', | ||
field=models.CharField(help_text="User-facing ID that is used on import/export. Should only contain alphanumeric characters or '_' '-' '.'", max_length=255, null=True, unique=True), | ||
), | ||
# Fill the field for created taxonomies | ||
migrations.RunPython(migrate_export_id, reverse), | ||
# Alter the field to not allowing null | ||
migrations.AlterField( | ||
model_name='taxonomy', | ||
name='export_id', | ||
field=models.CharField(help_text="User-facing ID that is used on import/export. Should only contain alphanumeric characters or '_' '-' '.'", max_length=255, null=False, unique=True), | ||
), | ||
] |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This generated a warning on the lint