Skip to content

Commit

Permalink
fix: Revert worksheet ID type (#1804)
Browse files Browse the repository at this point in the history
* fix: Revert worksheet ID type

* fix test
  • Loading branch information
faucomte97 committed Aug 13, 2023
1 parent ee0fcba commit c951949
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions aimmo/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class GameSerializer(serializers.Serializer):
settings = serializers.SerializerMethodField("get_settings_as_dict")
status = serializers.CharField(max_length=1, required=False)
class_id = serializers.SerializerMethodField()
worksheet_id = serializers.IntegerField()
worksheet_id = serializers.CharField(max_length=1, required=False)
era = serializers.SerializerMethodField("get_worksheet_era")

def get_class_id(self, game: Game):
Expand All @@ -22,9 +22,9 @@ def get_class_id(self, game: Game):

def get_worksheet_id(self, game: Game):
try:
return game.worksheet.id
return str(game.worksheet.id)
except AttributeError:
return 1
return "1"

def get_worksheet_era(self, game: Game):
try:
Expand All @@ -46,7 +46,7 @@ def update(self, instance, validated_data):

if "worksheet_id" in validated_data:
avatars = Avatar.objects.filter(game=instance)
worksheet = WORKSHEETS.get(instance.worksheet_id)
worksheet = WORKSHEETS.get(int(instance.worksheet_id))

for avatar in avatars:
avatar.code = worksheet.starter_code
Expand Down
4 changes: 2 additions & 2 deletions aimmo/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def expected_game_detail(class_id, worksheet_id):
"status": "r",
"settings": '{"GENERATOR": "Main", "OBSTACLE_RATIO": 0.1, "PICKUP_SPAWN_CHANCE": 0.1, "SCORE_DESPAWN_CHANCE": 0.05, "START_HEIGHT": 31, "START_WIDTH": 31, "TARGET_NUM_CELLS_PER_AVATAR": 16.0, "TARGET_NUM_PICKUPS_PER_AVATAR": 0.0, "TARGET_NUM_SCORE_LOCATIONS_PER_AVATAR": 0.5}',
"class_id": str(class_id),
"worksheet_id": worksheet_id,
"worksheet_id": str(worksheet_id),
}

expected_game_list = {
Expand Down Expand Up @@ -501,7 +501,7 @@ def expected_game_detail(class_id, worksheet_id):
"status": "r",
"settings": '{"GENERATOR": "Main", "OBSTACLE_RATIO": 0.1, "PICKUP_SPAWN_CHANCE": 0.1, "SCORE_DESPAWN_CHANCE": 0.05, "START_HEIGHT": 31, "START_WIDTH": 31, "TARGET_NUM_CELLS_PER_AVATAR": 16.0, "TARGET_NUM_PICKUPS_PER_AVATAR": 0.0, "TARGET_NUM_SCORE_LOCATIONS_PER_AVATAR": 0.5}',
"class_id": str(class_id),
"worksheet_id": worksheet_id,
"worksheet_id": str(worksheet_id),
}

expected_game_list = {
Expand Down

0 comments on commit c951949

Please sign in to comment.