diff --git a/game/migrations/0001_squashed_0025_levels_ordering_pt1.py b/game/migrations/0001_squashed_0025_levels_ordering_pt1.py index 78ff3ba8c..e6f3389f5 100644 --- a/game/migrations/0001_squashed_0025_levels_ordering_pt1.py +++ b/game/migrations/0001_squashed_0025_levels_ordering_pt1.py @@ -4,7 +4,7 @@ from django.db import models, migrations from django.conf import settings import json -from game.level_management import set_decor_inner, set_blocks_inner +from game.level_management import set_blocks_inner # Functions from the following migrations need manual copying. @@ -2527,6 +2527,21 @@ def delete_old_limit_level(apps, schema_editor): old_limit_level.delete() +def set_decor_inner(level, decor, LevelDecor): + """Helper method creating LevelDecor objects given a list of decor in dictionary form.""" + LevelDecor.objects.filter(level=level).delete() + + level_decors = [] + for data in decor: + level_decors.append( + LevelDecor( + level_id=level.id, x=data["x"], y=data["y"], decorName=data[ + "decorName"] + ) + ) + LevelDecor.objects.bulk_create(level_decors) + + # Add episode 7 to 9 # Add levels 62, 51, 59, 57, 60, 61, 70 def add_episode_7_to_9(apps, schema_editor): diff --git a/game/migrations/0026_levels_pt2.py b/game/migrations/0026_levels_pt2.py index cf1486cbf..996639f84 100644 --- a/game/migrations/0026_levels_pt2.py +++ b/game/migrations/0026_levels_pt2.py @@ -1,7 +1,7 @@ from __future__ import unicode_literals from django.db import migrations -from game.level_management import set_decor_inner, set_blocks_inner +from game.level_management import set_blocks_inner import json @@ -13,7 +13,18 @@ def change_levels(apps, schema_editor): Block = apps.get_model("game", "Block") def set_decor(level, decor): - set_decor_inner(level, decor, LevelDecor) + """Helper method creating LevelDecor objects given a list of decor in dictionary form.""" + LevelDecor.objects.filter(level=level).delete() + + level_decors = [] + for data in decor: + level_decors.append( + LevelDecor( + level_id=level.id, x=data["x"], y=data["y"], decorName=data[ + "decorName"] + ) + ) + LevelDecor.objects.bulk_create(level_decors) def set_blocks(level, blocks): set_blocks_inner(level, blocks, LevelBlock, Block) diff --git a/game/migrations/0032_cannot_turn_left_level.py b/game/migrations/0032_cannot_turn_left_level.py index 9db4c39e0..d28f023eb 100644 --- a/game/migrations/0032_cannot_turn_left_level.py +++ b/game/migrations/0032_cannot_turn_left_level.py @@ -1,5 +1,5 @@ from django.db import migrations -from game.level_management import set_decor_inner, set_blocks_inner +from game.level_management import set_blocks_inner import json @@ -12,7 +12,18 @@ def new_level(apps, schema_editor): Block = apps.get_model("game", "Block") def set_decor(level, decor): - set_decor_inner(level, decor, LevelDecor) + """Helper method creating LevelDecor objects given a list of decor in dictionary form.""" + LevelDecor.objects.filter(level=level).delete() + + level_decors = [] + for data in decor: + level_decors.append( + LevelDecor( + level_id=level.id, x=data["x"], y=data["y"], decorName=data[ + "decorName"] + ) + ) + LevelDecor.objects.bulk_create(level_decors) def set_blocks(level, blocks): set_blocks_inner(level, blocks, LevelBlock, Block) diff --git a/game/migrations/0033_recursion_level.py b/game/migrations/0033_recursion_level.py index 2df8d9cb6..b2a693f60 100644 --- a/game/migrations/0033_recursion_level.py +++ b/game/migrations/0033_recursion_level.py @@ -1,5 +1,5 @@ from django.db import migrations -from game.level_management import set_decor_inner, set_blocks_inner +from game.level_management import set_blocks_inner import json @@ -15,7 +15,18 @@ def new_level(apps, schema_editor): Block = apps.get_model("game", "Block") def set_decor(level, decor): - set_decor_inner(level, decor, LevelDecor) + """Helper method creating LevelDecor objects given a list of decor in dictionary form.""" + LevelDecor.objects.filter(level=level).delete() + + level_decors = [] + for data in decor: + level_decors.append( + LevelDecor( + level_id=level.id, x=data["x"], y=data["y"], decorName=data[ + "decorName"] + ) + ) + LevelDecor.objects.bulk_create(level_decors) def set_blocks(level, blocks): set_blocks_inner(level, blocks, LevelBlock, Block) diff --git a/game/migrations/0034_joes_level.py b/game/migrations/0034_joes_level.py index a5a00b5a3..215666770 100644 --- a/game/migrations/0034_joes_level.py +++ b/game/migrations/0034_joes_level.py @@ -1,5 +1,5 @@ from django.db import migrations -from game.level_management import set_decor_inner, set_blocks_inner +from game.level_management import set_blocks_inner import json @@ -12,7 +12,18 @@ def new_level(apps, schema_editor): Block = apps.get_model("game", "Block") def set_decor(level, decor): - set_decor_inner(level, decor, LevelDecor) + """Helper method creating LevelDecor objects given a list of decor in dictionary form.""" + LevelDecor.objects.filter(level=level).delete() + + level_decors = [] + for data in decor: + level_decors.append( + LevelDecor( + level_id=level.id, x=data["x"], y=data["y"], decorName=data[ + "decorName"] + ) + ) + LevelDecor.objects.bulk_create(level_decors) def set_blocks(level, blocks): set_blocks_inner(level, blocks, LevelBlock, Block) diff --git a/game/migrations/0035_disable_route_score_level_70.py b/game/migrations/0035_disable_route_score_level_70.py index ed0695c2e..b3649041d 100644 --- a/game/migrations/0035_disable_route_score_level_70.py +++ b/game/migrations/0035_disable_route_score_level_70.py @@ -1,6 +1,4 @@ from django.db import migrations -from game.level_management import set_decor_inner, set_blocks_inner -import json def disable_route_score(apps, schema_editor): diff --git a/game/migrations/0036_level_score_73.py b/game/migrations/0036_level_score_73.py index 0b331539e..f0928930f 100644 --- a/game/migrations/0036_level_score_73.py +++ b/game/migrations/0036_level_score_73.py @@ -1,6 +1,4 @@ from django.db import migrations -from game.level_management import set_decor_inner, set_blocks_inner -import json def update_level(apps, schema_editor): diff --git a/game/migrations/0037_level_score_79.py b/game/migrations/0037_level_score_79.py index 63bc0edad..7a406972f 100644 --- a/game/migrations/0037_level_score_79.py +++ b/game/migrations/0037_level_score_79.py @@ -1,6 +1,4 @@ from django.db import migrations -from game.level_management import set_decor_inner, set_blocks_inner -import json def update_level(apps, schema_editor): diff --git a/game/migrations/0038_level_score_40.py b/game/migrations/0038_level_score_40.py index 291165f57..1272e1d7a 100644 --- a/game/migrations/0038_level_score_40.py +++ b/game/migrations/0038_level_score_40.py @@ -1,5 +1,4 @@ from django.db import migrations -from game.level_management import set_decor_inner, set_blocks_inner import json diff --git a/game/migrations/0042_level_score_73.py b/game/migrations/0042_level_score_73.py index 3690a42d1..1d8b4b2e7 100644 --- a/game/migrations/0042_level_score_73.py +++ b/game/migrations/0042_level_score_73.py @@ -1,6 +1,4 @@ from django.db import migrations -from game.level_management import set_decor_inner, set_blocks_inner -import json def update_level(apps, schema_editor): diff --git a/game/migrations/0048_add_cow_field_and_blocks.py b/game/migrations/0048_add_cow_field_and_blocks.py index f7d95d4c9..d7face095 100644 --- a/game/migrations/0048_add_cow_field_and_blocks.py +++ b/game/migrations/0048_add_cow_field_and_blocks.py @@ -1,9 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -import json from django.db import models, migrations -from game.level_management import set_blocks_inner, set_decor_inner def add_cows_block(apps, schema_editor): diff --git a/game/migrations/0049_level_score_34.py b/game/migrations/0049_level_score_34.py index da1bc0439..84e22b21f 100644 --- a/game/migrations/0049_level_score_34.py +++ b/game/migrations/0049_level_score_34.py @@ -1,6 +1,4 @@ from django.db import migrations -from game.level_management import set_decor_inner, set_blocks_inner -import json def update_level(apps, schema_editor): diff --git a/game/migrations/0050_level_score_40.py b/game/migrations/0050_level_score_40.py index 02f49b2ff..abf5f7d6f 100644 --- a/game/migrations/0050_level_score_40.py +++ b/game/migrations/0050_level_score_40.py @@ -1,6 +1,4 @@ from django.db import migrations -from game.level_management import set_decor_inner, set_blocks_inner -import json def update_level(apps, schema_editor): diff --git a/game/migrations/0051_level_score_49.py b/game/migrations/0051_level_score_49.py index 8b16f2ab7..d927a5d06 100644 --- a/game/migrations/0051_level_score_49.py +++ b/game/migrations/0051_level_score_49.py @@ -1,5 +1,4 @@ from django.db import migrations -from game.level_management import set_decor_inner, set_blocks_inner import json diff --git a/game/migrations/0086_loop_levels.py b/game/migrations/0086_loop_levels.py index 84f6d546f..f400fd17e 100644 --- a/game/migrations/0086_loop_levels.py +++ b/game/migrations/0086_loop_levels.py @@ -3,7 +3,7 @@ from django.apps.registry import Apps from django.db import migrations -from game.level_management import set_decor_inner, set_blocks_inner +from game.level_management import set_blocks_inner def add_loop_levels(apps: Apps, *args): @@ -365,7 +365,18 @@ def add_loop_levels(apps: Apps, *args): ) def set_decor(level, decor): - set_decor_inner(level, decor, LevelDecor) + """Helper method creating LevelDecor objects given a list of decor in dictionary form.""" + LevelDecor.objects.filter(level=level).delete() + + level_decors = [] + for data in decor: + level_decors.append( + LevelDecor( + level_id=level.id, x=data["x"], y=data["y"], decorName=data[ + "decorName"] + ) + ) + LevelDecor.objects.bulk_create(level_decors) set_decor( level_110, diff --git a/game/migrations/0097_add_python_den_levels.py b/game/migrations/0097_add_python_den_levels.py index e9e6d0923..86fd893cb 100644 --- a/game/migrations/0097_add_python_den_levels.py +++ b/game/migrations/0097_add_python_den_levels.py @@ -2,7 +2,7 @@ from django.db import migrations -from game.level_management import set_decor_inner, set_blocks_inner +from game.level_management import set_blocks_inner def add_python_den_levels(apps, schema_editor): @@ -931,7 +931,18 @@ def add_python_den_decor(apps, schema_editor): LevelDecor = apps.get_model("game", "LevelDecor") def set_decor(level, decor): - set_decor_inner(level, decor, LevelDecor) + """Helper method creating LevelDecor objects given a list of decor in dictionary form.""" + LevelDecor.objects.filter(level=level).delete() + + level_decors = [] + for data in decor: + level_decors.append( + LevelDecor( + level_id=level.id, x=data["x"], y=data["y"], decorName=data[ + "decorName"] + ) + ) + LevelDecor.objects.bulk_create(level_decors) def bulk_copy_decor(old_level_name, new_level_name): old_level = Level.objects.get(name=old_level_name, default=True)