mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-10 14:14:17 +00:00
Serving Language, Generation, Version, Ability, Type
This commit is contained in:
parent
bcc7ea9df4
commit
b8cf2128a3
10 changed files with 839 additions and 76 deletions
|
@ -53,7 +53,10 @@ router.register(r"language", LanguageResource)
|
|||
router.register(r"move", MoveResource)
|
||||
router.register(r"nature", NatureResource)
|
||||
router.register(r"pokemon", PokemonResource)
|
||||
router.register(r"region", RegionResource)
|
||||
router.register(r"type", TypeResource)
|
||||
router.register(r"version", VersionResource)
|
||||
router.register(r"version-group", VersionGroupResource)
|
||||
|
||||
|
||||
###########################
|
||||
|
|
|
@ -730,8 +730,8 @@ for index, info in enumerate(data):
|
|||
if index > 0:
|
||||
|
||||
typeEfficacy = TypeEfficacy (
|
||||
damage_type_id = int(info[0]),
|
||||
target_type_id = int(info[1]),
|
||||
damage_type_id = Type.objects.get(pk = int(info[0])),
|
||||
target_type_id = Type.objects.get(pk = int(info[1])),
|
||||
damage_factor = int(info[2])
|
||||
)
|
||||
typeEfficacy.save()
|
||||
|
|
386
pokemon_v2/migrations/0007_auto_20150911_1436.py
Normal file
386
pokemon_v2/migrations/0007_auto_20150911_1436.py
Normal file
|
@ -0,0 +1,386 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pokemon_v2', '0006_auto_20150910_0357'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='ability',
|
||||
name='generation',
|
||||
field=models.ForeignKey(related_name='ability', blank=True, to='pokemon_v2.Generation', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='abilitychangedescription',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='abilitychangedescription_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='abilitydescription',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='abilitydescription_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='abilityflavortext',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='abilityflavortext_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='abilityname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='abilityname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='berryfirmnessname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='berryfirmnessname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='characteristicdescription',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='characteristicdescription_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='contesteffectdescription',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='contesteffectdescription_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='contesttypename',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='contesttypename_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='egggroupname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='egggroupname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='encounterconditionname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='encounterconditionname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='encounterconditionvaluename',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='encounterconditionvaluename_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='encountermethodname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='encountermethodname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='evolutiontriggername',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='evolutiontriggername_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='generationname',
|
||||
name='generation',
|
||||
field=models.ForeignKey(related_name='generationname', blank=True, to='pokemon_v2.Generation', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='generationname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='generationname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='growthratedescription',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='growthratedescription_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='itemcategoryname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='itemcategoryname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='itemdescription',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='itemdescription_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='itemflagdescription',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='itemflagdescription_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='itemflavortext',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='itemflavortext_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='itemflingeffectdescription',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='itemflingeffectdescription_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='itemgameindex',
|
||||
name='generation',
|
||||
field=models.ForeignKey(related_name='itemgameindex', blank=True, to='pokemon_v2.Generation', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='itemname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='itemname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='itempocketname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='itempocketname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='languagename',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='languagename_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='locationareaname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='locationareaname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='locationgameindex',
|
||||
name='generation',
|
||||
field=models.ForeignKey(related_name='locationgameindex', blank=True, to='pokemon_v2.Generation', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='locationname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='locationname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='move',
|
||||
name='generation',
|
||||
field=models.ForeignKey(related_name='move', blank=True, to='pokemon_v2.Generation', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='movebattlestylename',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='movebattlestylename_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='movedamageclassdescription',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='movedamageclassdescription_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='moveeffectchangedescription',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='moveeffectchangedescription_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='moveeffectdescription',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='moveeffectdescription_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='moveflagdescription',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='moveflagdescription_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='moveflavortext',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='moveflavortext_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='movemetaailmentname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='movemetaailmentname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='movemetacategorydescription',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='movemetacategorydescription_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='movename',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='movename_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='movetargetdescription',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='movetargetdescription_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='naturename',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='naturename_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='palparkareaname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='palparkareaname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='pokeathlonstatname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='pokeathlonstatname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='pokedexdescription',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='pokedexdescription_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='pokemoncolorname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='pokemoncolorname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='pokemonformgeneration',
|
||||
name='generation',
|
||||
field=models.ForeignKey(related_name='pokemonformgeneration', blank=True, to='pokemon_v2.Generation', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='pokemonformname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='pokemonformname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='pokemonhabitatname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='pokemonhabitatname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='pokemonmovemethodname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='pokemonmovemethodname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='pokemonshapename',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='pokemonshapename_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='pokemonspecies',
|
||||
name='generation',
|
||||
field=models.ForeignKey(related_name='pokemonspecies', blank=True, to='pokemon_v2.Generation', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='pokemonspeciesdescription',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='pokemonspeciesdescription_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='pokemonspeciesflavortext',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='pokemonspeciesflavortext_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='pokemonspeciesname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='pokemonspeciesname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='regionname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='regionname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='statname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='statname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='supercontesteffectdescription',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='supercontesteffectdescription_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='type',
|
||||
name='generation',
|
||||
field=models.ForeignKey(related_name='type', blank=True, to='pokemon_v2.Generation', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='typegameindex',
|
||||
name='generation',
|
||||
field=models.ForeignKey(related_name='typegameindex', blank=True, to='pokemon_v2.Generation', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='typename',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='typename_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='versiongroup',
|
||||
name='generation',
|
||||
field=models.ForeignKey(related_name='versiongroup', blank=True, to='pokemon_v2.Generation', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='versionname',
|
||||
name='language',
|
||||
field=models.ForeignKey(related_name='versionname_language', blank=True, to='pokemon_v2.Language', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
44
pokemon_v2/migrations/0008_auto_20150911_1444.py
Normal file
44
pokemon_v2/migrations/0008_auto_20150911_1444.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pokemon_v2', '0007_auto_20150911_1436'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='generation',
|
||||
name='region',
|
||||
field=models.ForeignKey(related_name='generation', blank=True, to='pokemon_v2.Region', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='location',
|
||||
name='region',
|
||||
field=models.ForeignKey(related_name='location', blank=True, to='pokemon_v2.Region', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='pokedex',
|
||||
name='region',
|
||||
field=models.ForeignKey(related_name='pokedex', blank=True, to='pokemon_v2.Region', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='regionname',
|
||||
name='region',
|
||||
field=models.ForeignKey(related_name='regionname', blank=True, to='pokemon_v2.Region', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='versiongroupregion',
|
||||
name='region',
|
||||
field=models.ForeignKey(related_name='versiongroupregion', blank=True, to='pokemon_v2.Region', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
110
pokemon_v2/migrations/0009_auto_20150911_1508.py
Normal file
110
pokemon_v2/migrations/0009_auto_20150911_1508.py
Normal file
|
@ -0,0 +1,110 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pokemon_v2', '0008_auto_20150911_1444'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='abilityflavortext',
|
||||
name='version_group',
|
||||
field=models.ForeignKey(related_name='abilityflavortext', blank=True, to='pokemon_v2.VersionGroup', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='encounter',
|
||||
name='version',
|
||||
field=models.ForeignKey(related_name='encounter', blank=True, to='pokemon_v2.Version', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='encounterslot',
|
||||
name='version_group',
|
||||
field=models.ForeignKey(related_name='encounterslot', blank=True, to='pokemon_v2.VersionGroup', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='itemflavortext',
|
||||
name='version_group',
|
||||
field=models.ForeignKey(related_name='itemflavortext', blank=True, to='pokemon_v2.VersionGroup', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='locationareaencounterrate',
|
||||
name='version',
|
||||
field=models.ForeignKey(related_name='locationareaencounterrate', blank=True, to='pokemon_v2.Version', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='movechange',
|
||||
name='version_group',
|
||||
field=models.ForeignKey(related_name='movechange', blank=True, to='pokemon_v2.VersionGroup', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='moveeffectchange',
|
||||
name='version_group',
|
||||
field=models.ForeignKey(related_name='moveeffectchange', blank=True, to='pokemon_v2.VersionGroup', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='moveflavortext',
|
||||
name='version_group',
|
||||
field=models.ForeignKey(related_name='moveflavortext', blank=True, to='pokemon_v2.VersionGroup', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='pokedexversiongroup',
|
||||
name='version_group',
|
||||
field=models.ForeignKey(related_name='pokedexversiongroup', blank=True, to='pokemon_v2.VersionGroup', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='pokemongameindex',
|
||||
name='version',
|
||||
field=models.ForeignKey(related_name='pokemongameindex', blank=True, to='pokemon_v2.Version', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='pokemonitem',
|
||||
name='version',
|
||||
field=models.ForeignKey(related_name='pokemonitem', blank=True, to='pokemon_v2.Version', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='pokemonmove',
|
||||
name='version_group',
|
||||
field=models.ForeignKey(related_name='pokemonmove', blank=True, to='pokemon_v2.VersionGroup', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='pokemonspeciesflavortext',
|
||||
name='version',
|
||||
field=models.ForeignKey(related_name='pokemonspeciesflavortext', blank=True, to='pokemon_v2.Version', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='version',
|
||||
name='version_group',
|
||||
field=models.ForeignKey(related_name='version', blank=True, to='pokemon_v2.VersionGroup', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='versiongrouppokemonmovemethod',
|
||||
name='version_group',
|
||||
field=models.ForeignKey(related_name='versiongrouppokemonmovemethod', blank=True, to='pokemon_v2.VersionGroup', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='versiongroupregion',
|
||||
name='version_group',
|
||||
field=models.ForeignKey(related_name='versiongroupregion', blank=True, to='pokemon_v2.VersionGroup', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
44
pokemon_v2/migrations/0010_auto_20150911_2018.py
Normal file
44
pokemon_v2/migrations/0010_auto_20150911_2018.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pokemon_v2', '0009_auto_20150911_1508'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='move',
|
||||
name='type',
|
||||
field=models.ForeignKey(related_name='move', blank=True, to='pokemon_v2.Type', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='movechange',
|
||||
name='type',
|
||||
field=models.ForeignKey(related_name='movechange', blank=True, to='pokemon_v2.Type', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='pokemontype',
|
||||
name='type',
|
||||
field=models.ForeignKey(related_name='pokemontype', blank=True, to='pokemon_v2.Type', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='typegameindex',
|
||||
name='type',
|
||||
field=models.ForeignKey(related_name='typegameindex', blank=True, to='pokemon_v2.Type', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='typename',
|
||||
name='type',
|
||||
field=models.ForeignKey(related_name='typename', blank=True, to='pokemon_v2.Type', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
26
pokemon_v2/migrations/0011_auto_20150911_2048.py
Normal file
26
pokemon_v2/migrations/0011_auto_20150911_2048.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pokemon_v2', '0010_auto_20150911_2018'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='typeefficacy',
|
||||
name='damage_type_id',
|
||||
field=models.ForeignKey(related_name='damage_type', blank=True, to='pokemon_v2.Type', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='typeefficacy',
|
||||
name='target_type_id',
|
||||
field=models.ForeignKey(related_name='target_type', blank=True, to='pokemon_v2.Type', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
|
@ -112,7 +112,7 @@ class HasGameIndex(models.Model):
|
|||
|
||||
class HasGeneration(models.Model):
|
||||
|
||||
generation = models.ForeignKey('Generation', blank=True, null=True)
|
||||
generation = models.ForeignKey('Generation', blank=True, null=True, related_name="%(class)s")
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
@ -328,7 +328,7 @@ class HasPokemonSpecies(models.Model):
|
|||
|
||||
class HasRegion(models.Model):
|
||||
|
||||
region = models.ForeignKey('Region', blank=True, null=True)
|
||||
region = models.ForeignKey('Region', blank=True, null=True, related_name="%(class)s")
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
@ -352,7 +352,7 @@ class HasStat(models.Model):
|
|||
|
||||
class HasType(models.Model):
|
||||
|
||||
type = models.ForeignKey('Type', blank=True, null=True)
|
||||
type = models.ForeignKey('Type', blank=True, null=True, related_name="%(class)s")
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
@ -360,7 +360,7 @@ class HasType(models.Model):
|
|||
|
||||
class HasVersion(models.Model):
|
||||
|
||||
version = models.ForeignKey('Version', blank=True, null=True)
|
||||
version = models.ForeignKey('Version', blank=True, null=True, related_name="%(class)s")
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
@ -368,7 +368,7 @@ class HasVersion(models.Model):
|
|||
|
||||
class HasVersionGroup(models.Model):
|
||||
|
||||
version_group = models.ForeignKey('VersionGroup', blank=True, null=True)
|
||||
version_group = models.ForeignKey('VersionGroup', blank=True, null=True, related_name="%(class)s")
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
@ -513,9 +513,9 @@ class TypeGameIndex(HasType, HasGeneration, HasGameIndex):
|
|||
|
||||
class TypeEfficacy(models.Model):
|
||||
|
||||
damage_type_id = models.IntegerField()
|
||||
damage_type_id = models.ForeignKey('Type', blank=True, null=True, related_name="damage_type")
|
||||
|
||||
target_type_id = models.IntegerField()
|
||||
target_type_id = models.ForeignKey('Type', blank=True, null=True, related_name="target_type")
|
||||
|
||||
damage_factor = models.IntegerField()
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
from rest_framework import serializers
|
||||
from collections import OrderedDict
|
||||
|
||||
"""
|
||||
PokeAPI v2 serializers
|
||||
PokeAPI v2 serializers in order of dependency
|
||||
"""
|
||||
|
||||
from .models import *
|
||||
|
@ -38,6 +39,117 @@ class LanguageDetailSerializer(serializers.ModelSerializer):
|
|||
fields = ('name', 'official', 'iso639', 'iso3166', 'id', 'names')
|
||||
|
||||
|
||||
########################
|
||||
# REGION SERIALIZERS #
|
||||
########################
|
||||
|
||||
class RegionNameSerializer(serializers.ModelSerializer):
|
||||
|
||||
language = LanguageSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = RegionName
|
||||
fields = ('name', 'language')
|
||||
|
||||
|
||||
class RegionSummarySerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Region
|
||||
fields = ('name', 'url')
|
||||
|
||||
|
||||
class RegionDetailSerializer(serializers.ModelSerializer):
|
||||
|
||||
names = RegionNameSerializer(many=True, read_only=True, source="regionname")
|
||||
|
||||
class Meta:
|
||||
model = Region
|
||||
fields = ('id', 'name', 'names')
|
||||
|
||||
|
||||
############################
|
||||
# GENERATION SERIALIZERS #
|
||||
############################
|
||||
|
||||
class GenerationNameSerializer(serializers.ModelSerializer):
|
||||
|
||||
language = LanguageSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = GenerationName
|
||||
fields = ('name', 'language')
|
||||
|
||||
|
||||
class GenerationSummarySerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Generation
|
||||
fields = ('name', 'url')
|
||||
|
||||
|
||||
class GenerationDetailSerializer(serializers.ModelSerializer):
|
||||
|
||||
region = RegionSummarySerializer()
|
||||
names = GenerationNameSerializer(many=True, read_only=True, source="generationname")
|
||||
|
||||
class Meta:
|
||||
model = Generation
|
||||
fields = ('id', 'name', 'region', 'names')
|
||||
|
||||
|
||||
#########################
|
||||
# VERSION SERIALIZERS #
|
||||
#########################
|
||||
|
||||
class VersionNameSerializer(serializers.ModelSerializer):
|
||||
|
||||
language = LanguageSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = VersionName
|
||||
fields = ('name', 'language')
|
||||
|
||||
|
||||
class VersionSummarySerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Version
|
||||
fields = ('name', 'url')
|
||||
|
||||
|
||||
class VersionDetailSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
Should have a link to Version Group info but the Circular
|
||||
dependency and compilation order fight eachother and I'm
|
||||
not sure how to add anything other than a hyperlink
|
||||
"""
|
||||
|
||||
names = VersionNameSerializer(many=True, read_only=True, source="versionname")
|
||||
version_group_url = serializers.HyperlinkedRelatedField(read_only='True', source="version_group", view_name='versiongroup-detail')
|
||||
|
||||
class Meta:
|
||||
model = Version
|
||||
fields = ('id', 'name', 'names', 'version_group_url')
|
||||
|
||||
|
||||
class VersionGroupSummarySerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = VersionGroup
|
||||
fields = ('name', 'url')
|
||||
|
||||
|
||||
class VersionGroupDetailSerializer(serializers.ModelSerializer):
|
||||
|
||||
generation = GenerationSummarySerializer()
|
||||
versions = VersionSummarySerializer(many=True, read_only=True, source="version")
|
||||
|
||||
class Meta:
|
||||
model = VersionGroup
|
||||
fields = ('id', 'name', 'order', 'generation', 'versions')
|
||||
|
||||
|
||||
#########################
|
||||
# ABILITY SERIALIZERS #
|
||||
#########################
|
||||
|
@ -55,6 +167,7 @@ class AbilityFlavorTextSerializer(serializers.ModelSerializer):
|
|||
|
||||
text = serializers.CharField(source="flavor_text")
|
||||
language = LanguageSummarySerializer()
|
||||
version_group = VersionGroupSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = AbilityFlavorText
|
||||
|
@ -76,33 +189,12 @@ class AbilitySummarySerializer(serializers.HyperlinkedModelSerializer):
|
|||
model = Ability
|
||||
|
||||
|
||||
class AbilityDetailSerializer(serializers.HyperlinkedModelSerializer):
|
||||
class AbilityDetailSerializer(serializers.ModelSerializer):
|
||||
|
||||
descriptions = AbilityDescriptionSerializer(many=True, read_only=True, source="abilitydescription")
|
||||
flavor_text_entries = AbilityFlavorTextSerializer(many=True, read_only=True, source="abilityflavortext")
|
||||
names = AbilityNameSerializer(many=True, read_only=True, source="abilityname")
|
||||
|
||||
# names = serializers.SerializerMethodField('get_names_by_language')
|
||||
# descriptions = serializers.SerializerMethodField('get_descriptions_by_language')
|
||||
# flavor_text_entries = serializers.SerializerMethodField('get_flavor_text_by_language')
|
||||
|
||||
# def get_names_by_language(self, obj):
|
||||
# language_filter = self.context['request'].query_params['language']
|
||||
# names = AbilityName.objects.filter(ability=obj, language=9)
|
||||
# serializer = AbilityNameSerializer(names, many=True, context=self.context)
|
||||
# return serializer.data
|
||||
|
||||
# def get_flavor_text_by_language(self, obj):
|
||||
# language_filter = self.context['request'].query_params['language']
|
||||
# flavor_text_entries = AbilityFlavorText.objects.filter(ability=obj, language=9)
|
||||
# serializer = AbilityFlavorTextSerializer(flavor_text_entries, many=True, context=self.context)
|
||||
# return serializer.data
|
||||
|
||||
# def get_descriptions_by_language(self, obj):
|
||||
# language_filter = self.context['request'].query_params['language']
|
||||
# descriptions = AbilityDescription.objects.filter(ability=obj, language=9)
|
||||
# serializer = AbilityDescriptionSerializer(descriptions, many=True, context=self.context)
|
||||
# return serializer.data
|
||||
generation = GenerationSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = Ability
|
||||
|
@ -117,6 +209,84 @@ class AbilityDetailSerializer(serializers.HyperlinkedModelSerializer):
|
|||
)
|
||||
|
||||
|
||||
######################
|
||||
# TYPE SERIALIZERS #
|
||||
######################
|
||||
|
||||
class TypeEfficacySerializer(serializers.ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = TypeEfficacy
|
||||
|
||||
|
||||
class TypeNameSerializer(serializers.ModelSerializer):
|
||||
|
||||
language = LanguageSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = TypeName
|
||||
fields = ('name', 'language')
|
||||
|
||||
|
||||
class TypeSummarySerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Type
|
||||
fields = ('name', 'url')
|
||||
|
||||
|
||||
class TypeDetailSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
Serializer for the Type resource
|
||||
"""
|
||||
generation = GenerationSummarySerializer()
|
||||
names = AbilityNameSerializer(many=True, read_only=True, source="typename")
|
||||
damage_relations = serializers.SerializerMethodField('get_type_relationships')
|
||||
|
||||
class Meta:
|
||||
model = Type
|
||||
fields = ('id', 'name', 'move_damage_class', 'generation', 'names', 'damage_relations')
|
||||
|
||||
def get_type_relationships(self, obj):
|
||||
|
||||
relations = OrderedDict()
|
||||
relations['no_damage_to'] = []
|
||||
relations['half_damage_to'] = []
|
||||
relations['double_damage_to'] = []
|
||||
|
||||
relations['no_damage_from'] = []
|
||||
relations['half_damage_from'] = []
|
||||
relations['double_damage_from'] = []
|
||||
|
||||
# Damage To
|
||||
results = TypeEfficacy.objects.filter(damage_type_id=obj)
|
||||
serializer = TypeEfficacySerializer(results, many=True, context=self.context)
|
||||
|
||||
for relation in serializer.data:
|
||||
type = Type.objects.get(id=relation['target_type_id'])
|
||||
if relation['damage_factor'] == 200:
|
||||
relations['double_damage_to'].append(TypeSummarySerializer(type, context=self.context).data)
|
||||
elif relation['damage_factor'] == 50:
|
||||
relations['half_damage_to'].append(TypeSummarySerializer(type, context=self.context).data)
|
||||
elif relation['damage_factor'] == 0:
|
||||
relations['no_damage_to'].append(TypeSummarySerializer(type, context=self.context).data)
|
||||
|
||||
# Damage From
|
||||
results = TypeEfficacy.objects.filter(target_type_id=obj)
|
||||
serializer = TypeEfficacySerializer(results, many=True, context=self.context)
|
||||
|
||||
for relation in serializer.data:
|
||||
type = Type.objects.get(id=relation['damage_type_id'])
|
||||
if relation['damage_factor'] == 200:
|
||||
relations['double_damage_from'].append(TypeSummarySerializer(type, context=self.context).data)
|
||||
elif relation['damage_factor'] == 50:
|
||||
relations['half_damage_from'].append(TypeSummarySerializer(type, context=self.context).data)
|
||||
elif relation['damage_factor'] == 0:
|
||||
relations['no_damage_from'].append(TypeSummarySerializer(type, context=self.context).data)
|
||||
|
||||
return relations
|
||||
|
||||
|
||||
|
||||
#########################
|
||||
# BERRY SERIALIZERS #
|
||||
|
@ -162,14 +332,6 @@ class GenderSerializer(serializers.ModelSerializer):
|
|||
model = Gender
|
||||
|
||||
|
||||
class GenerationSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
Serializer for the Ability resource
|
||||
"""
|
||||
class Meta:
|
||||
model = Generation
|
||||
|
||||
|
||||
class GrowthRateSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
Serializer for the GrowthRate resource
|
||||
|
@ -186,14 +348,6 @@ class ItemSerializer(serializers.ModelSerializer):
|
|||
model = Item
|
||||
|
||||
|
||||
class LanguageSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
Serializer for the Language resource
|
||||
"""
|
||||
class Meta:
|
||||
model = Language
|
||||
|
||||
|
||||
class LocationSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
Serializer for the Location resource
|
||||
|
@ -232,27 +386,3 @@ class PokemonSerializer(serializers.ModelSerializer):
|
|||
"""
|
||||
class Meta:
|
||||
model = Pokemon
|
||||
|
||||
|
||||
class RegionSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
Serializer for the Region resource
|
||||
"""
|
||||
class Meta:
|
||||
model = Region
|
||||
|
||||
|
||||
class TypeSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
Serializer for the Type resource
|
||||
"""
|
||||
class Meta:
|
||||
model = Type
|
||||
|
||||
|
||||
class VersionSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
Serializer for the Version resource
|
||||
"""
|
||||
class Meta:
|
||||
model = Version
|
|
@ -69,8 +69,8 @@ class AbilityResource(PokeapiCommonViewset):
|
|||
class GenerationResource(PokeapiCommonViewset):
|
||||
|
||||
queryset = Generation.objects.all()
|
||||
serializer_class = GenerationSerializer
|
||||
|
||||
serializer_class = GenerationDetailSerializer
|
||||
list_serializer_class = GenerationSummarySerializer
|
||||
|
||||
class LanguageResource(PokeapiCommonViewset):
|
||||
|
||||
|
@ -96,9 +96,29 @@ class PokemonResource(PokeapiCommonViewset):
|
|||
serializer_class = PokemonSerializer
|
||||
|
||||
|
||||
class RegionResource(PokeapiCommonViewset):
|
||||
|
||||
queryset = Region.objects.all()
|
||||
serializer_class = RegionDetailSerializer
|
||||
list_serializer_class = RegionSummarySerializer
|
||||
|
||||
|
||||
class TypeResource(PokeapiCommonViewset):
|
||||
|
||||
queryset = Type.objects.all()
|
||||
serializer_class = TypeSerializer
|
||||
serializer_class = TypeDetailSerializer
|
||||
list_serializer_class = TypeSummarySerializer
|
||||
|
||||
|
||||
class VersionResource(PokeapiCommonViewset):
|
||||
|
||||
queryset = Version.objects.all()
|
||||
serializer_class = VersionDetailSerializer
|
||||
list_serializer_class = VersionSummarySerializer
|
||||
|
||||
|
||||
class VersionGroupResource(PokeapiCommonViewset):
|
||||
|
||||
queryset = VersionGroup.objects.all()
|
||||
serializer_class = VersionGroupDetailSerializer
|
||||
list_serializer_class = VersionGroupSummarySerializer
|
||||
|
|
Loading…
Reference in a new issue