-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: rename episodes and levels (#1581)
* fix: rename episodes and levels * feedback * fix: remove whitespaces
- Loading branch information
Showing
3 changed files
with
63 additions
and
28 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
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,35 @@ | ||
from django.apps.registry import Apps | ||
from django.db import migrations | ||
|
||
|
||
def rename_episodes(apps: Apps, *args): | ||
Episode = apps.get_model("game", "Episode") | ||
|
||
def update_episode_name(pk: int, name: str): | ||
episode = Episode.objects.get(pk=pk) | ||
episode.name = name | ||
episode.save() | ||
|
||
update_episode_name(pk=12, name="Counted Loops Using While") | ||
update_episode_name(pk=13, name="Indeterminate While Loops - coming soon") | ||
|
||
|
||
def undo_rename_episodes(apps: Apps, *args): | ||
Episode = apps.get_model("game", "Episode") | ||
|
||
def update_episode_name(pk: int, name: str): | ||
episode = Episode.objects.get(pk=pk) | ||
episode.name = name | ||
episode.save() | ||
|
||
update_episode_name(pk=12, name="Sequencing and Counted Loops") | ||
update_episode_name(pk=13, name="Indeterminate WHILE Loops - coming soon") | ||
|
||
class Migration(migrations.Migration): | ||
dependencies = [("game", "0087_workspace_python_view_enabled")] | ||
operations = [ | ||
migrations.RunPython( | ||
rename_episodes, | ||
reverse_code=undo_rename_episodes, | ||
) | ||
] |
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