From 3fa2b6952f8c3c8a1f7ef7a9bb273680db789c17 Mon Sep 17 00:00:00 2001 From: Naramsim Date: Wed, 8 Nov 2023 10:22:56 +0100 Subject: [PATCH] fix: don't add or replace parts of the sprites' URL --- pokemon_v2/serializers.py | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/pokemon_v2/serializers.py b/pokemon_v2/serializers.py index ac1b947c..046ca033 100644 --- a/pokemon_v2/serializers.py +++ b/pokemon_v2/serializers.py @@ -1507,13 +1507,6 @@ class ItemDetailSerializer(serializers.ModelSerializer): sprites_object = ItemSprites.objects.get(item_id=obj) sprites_data = ItemSpritesSerializer(sprites_object, context=self.context).data sprites_data = json.loads(sprites_data["sprites"]) - host = "raw.githubusercontent.com/PokeAPI/sprites/master/" - - for key in sprites_data: - if sprites_data[key]: - sprites_data[key] = ( - "https://" + host + sprites_data[key].replace("/media/", "") - ) return sprites_data @@ -2689,14 +2682,6 @@ class PokemonFormDetailSerializer(serializers.ModelSerializer): ).data sprites_data = json.loads(sprites_data["sprites"]) - host = "raw.githubusercontent.com/PokeAPI/sprites/master/" - - for key in sprites_data: - if sprites_data[key]: - sprites_data[key] = ( - "https://" + host + sprites_data[key].replace("/media/", "") - ) - return sprites_data def get_pokemon_form_types(self, obj): @@ -2956,20 +2941,8 @@ class PokemonDetailSerializer(serializers.ModelSerializer): sprites_data = PokemonSpritesSerializer( sprites_object, context=self.context ).data - sprites_data = json.loads(sprites_data["sprites"]) - host = "raw.githubusercontent.com/PokeAPI/sprites/master/" - def replace_sprite_url(d): - for key, value in d.items(): - if isinstance(value, dict): - replace_sprite_url(value) - else: - if d[key]: - d[key] = "https://" + host + d[key].replace("/media/", "") - - replace_sprite_url(sprites_data) - - return sprites_data + return json.loads(sprites_data["sprites"]) def get_pokemon_moves(self, obj):