style: Run black formatter on source

This commit is contained in:
FallenDeity 2024-02-03 00:32:51 +05:30
parent 02baf0b3ef
commit 4828b93860
5 changed files with 32 additions and 15 deletions

View file

@ -63,7 +63,9 @@ for root, dirs, files in os.walk(CRIES_DIR):
def file_path_or_none(file_name, image_file=True):
if not image_file:
return (
SOUND_DIR.format(file_name=file_name) if file_name in RESOURCE_CRIES else None
SOUND_DIR.format(file_name=file_name)
if file_name in RESOURCE_CRIES
else None
)
return (
MEDIA_DIR.format(file_name=file_name) if file_name in RESOURCE_IMAGES else None

View file

@ -5,21 +5,37 @@ import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('pokemon_v2', '0014_auto_20231121_1209'),
("pokemon_v2", "0014_auto_20231121_1209"),
]
operations = [
migrations.CreateModel(
name='PokemonCries',
name="PokemonCries",
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('cries', models.JSONField()),
('pokemon', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='pokemoncries', to='pokemon_v2.pokemon')),
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("cries", models.JSONField()),
(
"pokemon",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="pokemoncries",
to="pokemon_v2.pokemon",
),
),
],
options={
'abstract': False,
"abstract": False,
},
),
]

View file

@ -1800,4 +1800,3 @@ class PokemonSprites(HasPokemon):
class PokemonCries(HasPokemon):
cries = models.JSONField()

View file

@ -2752,7 +2752,7 @@ class PokemonDetailSerializer(serializers.ModelSerializer):
def get_pokemon_sprites(self, obj):
sprites_object = PokemonSprites.objects.get(pokemon_id=obj)
return sprites_object.sprites
def get_pokemon_cries(self, obj):
cries_object = PokemonCries.objects.get(pokemon_id=obj)
return cries_object.cries

View file

@ -1724,17 +1724,18 @@ class APIData:
pokemon_sprites.save()
return pokemon_sprites
@classmethod
def setup_pokemon_cries_data(cls, pokemon, latest=True, legacy=False):
cries_path = "https://raw.githubusercontent.com/PokeAPI/cries/main/cries/pokemon/%s.ogg"
cries_path = (
"https://raw.githubusercontent.com/PokeAPI/cries/main/cries/pokemon/%s.ogg"
)
cries = {
"latest": cries_path % f"latest/{pokemon.id}" if latest else None,
"legacy": cries_path % f"legacy/{pokemon.id}" if legacy else None,
}
pokemon_cries = PokemonCries.objects.create(
pokemon=pokemon,
cries=json.dumps(cries)
pokemon=pokemon, cries=json.dumps(cries)
)
pokemon_cries.save()
return pokemon_cries
@ -5098,7 +5099,6 @@ class APITests(APIData, APITestCase):
"{}".format(cries_data["legacy"]),
)
def test_pokemon_form_api(self):
pokemon_species = self.setup_pokemon_species_data()
pokemon = self.setup_pokemon_data(pokemon_species=pokemon_species)