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: Scoreboard issue with new levels #1584

Merged
merged 6 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion game/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ def __init__(self, *args, **kwargs):
# Each tuple in choices has two elements, id and name of each level
# First element is the actual value set on the model
# Second element is the string displayed on the dropdown menu
episodes_choices = ((episode.id, episode.name) for episode in Episode.objects.all())
episodes_choices = (
(episode.id, episode.name)
for episode in Episode.objects.filter(in_development=False)
)
self.fields["episodes"] = forms.MultipleChoiceField(
choices=itertools.chain(episodes_choices),
widget=forms.CheckboxSelectMultiple(),
Expand Down
30 changes: 30 additions & 0 deletions game/migrations/0089_episodes_in_development.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from django.apps.registry import Apps
from django.db import migrations


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

for i in range(13, 16):
episode = Episode.objects.get(pk=i)
episode.in_development = True
episode.save()


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

Check warning on line 15 in game/migrations/0089_episodes_in_development.py

View check run for this annotation

Codecov / codecov/patch

game/migrations/0089_episodes_in_development.py#L15

Added line #L15 was not covered by tests

for i in range(13, 16):
episode = Episode.objects.get(pk=i)
episode.in_development = False
episode.save()

Check warning on line 20 in game/migrations/0089_episodes_in_development.py

View check run for this annotation

Codecov / codecov/patch

game/migrations/0089_episodes_in_development.py#L17-L20

Added lines #L17 - L20 were not covered by tests


class Migration(migrations.Migration):
dependencies = [("game", "0088_rename_episodes")]
operations = [
migrations.RunPython(
mark_episodes_in_development,
reverse_code=unmark_episodes_in_development,
)
]
Loading
Loading