Skip to content
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

fix: Rename old coming soon episodes #1723

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions game/migrations/0101_rename_episodes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from django.apps.registry import Apps
from django.db import migrations


def rename_episodes(apps: Apps, *args):
Episode = apps.get_model("game", "Episode")

episode13 = Episode.objects.get(pk=13)
episode14 = Episode.objects.get(pk=14)
episode15 = Episode.objects.get(pk=15)

episode13.name = "Indeterminate Loops"
episode14.name = "Selection in a Loop"
episode15.name = "For Loops"

episode13.save()
episode14.save()
episode15.save()


def unrename_episodes(apps: Apps, *args):
Episode = apps.get_model("game", "Episode")

episode13 = Episode.objects.get(pk=13)
episode14 = Episode.objects.get(pk=14)
episode15 = Episode.objects.get(pk=15)

episode13.name = "Indeterminate While Loops - coming soon"
episode14.name = "Selection in a Loop - coming soon"
episode15.name = "For Loops - coming soon"

episode13.save()
episode14.save()
episode15.save()


class Migration(migrations.Migration):

dependencies = [("game", "0100_reorder_python_levels")]

operations = [
migrations.RunPython(
code=rename_episodes, reverse_code=unrename_episodes
)
]