mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-10 14:14:17 +00:00
fished serving almost all data (with the exception of machines and some csv files that didnt have data yet but have been updated in veekuns repo. TESTS STILL NEED TO BE DONE.
This commit is contained in:
commit
aa1d7d9939
8 changed files with 544 additions and 123 deletions
|
@ -48,6 +48,7 @@ from pokemon_v2.views import *
|
|||
router = routers.DefaultRouter()
|
||||
|
||||
router.register(r"ability", AbilityResource)
|
||||
router.register(r"ability-change", AbilityChangeResource)
|
||||
router.register(r"berry", BerryResource)
|
||||
router.register(r"berry-firmness", BerryFirmnessResource)
|
||||
router.register(r"characteristic", CharacteristicResource)
|
||||
|
@ -60,6 +61,7 @@ router.register(r"encounter-condition-value", EncounterConditionValueResource) #
|
|||
router.register(r"evolution-chain", EvolutionChainResource)
|
||||
router.register(r"evolution-trigger", EvolutionTriggerResource)
|
||||
router.register(r"generation", GenerationResource)
|
||||
router.register(r"gender", GenderResource)
|
||||
router.register(r"growth-rate", GrowthRateResource)
|
||||
router.register(r"item", ItemResource)
|
||||
router.register(r"item-category", ItemCategoryResource)
|
||||
|
@ -69,13 +71,16 @@ router.register(r"item-pocket", ItemPocketResource)
|
|||
router.register(r"language", LanguageResource)
|
||||
router.register(r"location", LocationResource)
|
||||
router.register(r"location-area", LocationAreaResource) # ?
|
||||
# router.register(r"machine", MachineResource)
|
||||
router.register(r"move", MoveResource)
|
||||
router.register(r"move-ailment", MoveMetaAilmentResource)
|
||||
router.register(r"move-battle-style", MoveBattleStyleResource)
|
||||
router.register(r"move-category", MoveMetaCategoryResource)
|
||||
router.register(r"move-damage-class", MoveDamageClassResource)
|
||||
router.register(r"move-learn-method", MoveLearnMethodResource)
|
||||
router.register(r"move-target", MoveTargetResource)
|
||||
router.register(r"nature", NatureResource)
|
||||
router.register(r"pal-park-area", PalParkAreaResource)
|
||||
router.register(r"pokedex", PokedexResource)
|
||||
router.register(r"pokemon", PokemonResource)
|
||||
router.register(r"pokemon-habitat", PokemonHabitatResource)
|
||||
|
@ -83,6 +88,7 @@ router.register(r"pokemon-shape", PokemonShapeResource)
|
|||
router.register(r"pokemon-species", PokemonSpeciesResource)
|
||||
router.register(r"pokemon-color", PokemonColorResource)
|
||||
router.register(r"pokemon-form", PokemonFormResource)
|
||||
router.register(r"pokeathlon-stat", PokeathlonStatResource)
|
||||
router.register(r"region", RegionResource)
|
||||
router.register(r"stat", StatResource)
|
||||
router.register(r"super-contest-effect", SuperContestEffectResource)
|
||||
|
|
|
@ -308,10 +308,9 @@ for index, info in enumerate(data):
|
|||
|
||||
|
||||
|
||||
|
||||
###############
|
||||
# ABILITIES #
|
||||
###############
|
||||
# ###############
|
||||
# # ABILITIES #
|
||||
# ###############
|
||||
|
||||
clearTable(Ability)
|
||||
data = loadData('abilities.csv')
|
||||
|
@ -342,6 +341,20 @@ for index, info in enumerate(data):
|
|||
abilityName.save()
|
||||
|
||||
|
||||
clearTable(AbilityChange)
|
||||
data = loadData('ability_changelog.csv')
|
||||
|
||||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
abilityName = AbilityChange (
|
||||
id = int(info[0]),
|
||||
ability = Ability.objects.get(pk = int(info[1])),
|
||||
version_group = VersionGroup.objects.get(pk = int(info[2]))
|
||||
)
|
||||
abilityName.save()
|
||||
|
||||
|
||||
clearTable(AbilityEffectText)
|
||||
data = loadData('ability_prose.csv')
|
||||
|
||||
|
@ -357,6 +370,20 @@ for index, info in enumerate(data):
|
|||
abilityDesc.save()
|
||||
|
||||
|
||||
clearTable(AbilityChangeEffectText)
|
||||
data = loadData('ability_changelog_prose.csv')
|
||||
|
||||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
abilityChangeEffectText = AbilityChangeEffectText (
|
||||
ability_change = AbilityChange.objects.get(pk = int(info[0])),
|
||||
language = Language.objects.get(pk = int(info[1])),
|
||||
effect = info[2]
|
||||
)
|
||||
abilityChangeEffectText.save()
|
||||
|
||||
|
||||
clearTable(AbilityFlavorText)
|
||||
data = loadData('ability_flavor_text.csv')
|
||||
|
||||
|
@ -762,7 +789,7 @@ for index, info in enumerate(data):
|
|||
if index > 0:
|
||||
|
||||
model = MoveEffectEffectText (
|
||||
move_effect = MoveEffect.objects.get(pk = int(info[1])),
|
||||
move_effect = MoveEffect.objects.get(pk = int(info[0])),
|
||||
language = Language.objects.get(pk = int(info[1])),
|
||||
short_effect = info[2],
|
||||
effect = info[3]
|
||||
|
@ -797,6 +824,7 @@ for index, info in enumerate(data):
|
|||
)
|
||||
model.save()
|
||||
|
||||
|
||||
clearTable(MoveLearnMethod)
|
||||
data = loadData('pokemon_move_methods.csv')
|
||||
|
||||
|
@ -810,6 +838,19 @@ for index, info in enumerate(data):
|
|||
model.save()
|
||||
|
||||
|
||||
clearTable(VersionGroupMoveLearnMethod)
|
||||
data = loadData('version_group_pokemon_move_methods.csv')
|
||||
|
||||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
versionGroupMoveLearnMethod = VersionGroupMoveLearnMethod (
|
||||
version_group = VersionGroup.objects.get(pk = int(info[0])),
|
||||
move_learn_method = MoveLearnMethod.objects.get(pk = int(info[1])),
|
||||
)
|
||||
versionGroupMoveLearnMethod.save()
|
||||
|
||||
|
||||
clearTable(MoveLearnMethodName)
|
||||
clearTable(MoveLearnMethodDescription)
|
||||
data = loadData('pokemon_move_method_prose.csv')
|
||||
|
@ -1385,7 +1426,7 @@ for index, info in enumerate(data):
|
|||
|
||||
model = NatureBattleStylePreference (
|
||||
nature = Nature.objects.get(pk = int(info[0])),
|
||||
move_battle_style_id = int(info[1]),
|
||||
move_battle_style = MoveBattleStyle.objects.get(pk = int(info[1])),
|
||||
low_hp_preference = info[2],
|
||||
high_hp_preference = info[3]
|
||||
)
|
||||
|
@ -1601,15 +1642,15 @@ data = loadData('location_areas.csv')
|
|||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
location = Location.objects.get(pk = int(info[1]))
|
||||
location = Location.objects.get(pk = int(info[1]))
|
||||
|
||||
model = LocationArea (
|
||||
id = int(info[0]),
|
||||
location = location,
|
||||
game_index = int(info[2]),
|
||||
name = '{}-{}'.format(location.name, info[3]) if info[3] else '{}-{}'.format(location.name, 'area')
|
||||
)
|
||||
model.save()
|
||||
model = LocationArea (
|
||||
id = int(info[0]),
|
||||
location = location,
|
||||
game_index = int(info[2]),
|
||||
name = '{}-{}'.format(location.name, info[3]) if info[3] else '{}-{}'.format(location.name, 'area')
|
||||
)
|
||||
model.save()
|
||||
|
||||
|
||||
clearTable(LocationAreaName)
|
||||
|
@ -2227,6 +2268,7 @@ for index, info in enumerate(data):
|
|||
model = PalPark (
|
||||
pokemon_species = PokemonSpecies.objects.get(pk = int(info[0])),
|
||||
pal_park_area = PalParkArea.objects.get(pk = int(info[1])),
|
||||
rate = int(info[2])
|
||||
base_score = int(info[2]),
|
||||
rate = int(info[3])
|
||||
)
|
||||
model.save()
|
||||
|
|
|
@ -6,7 +6,7 @@ from django.db import models, migrations
|
|||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
# replaces = [(b'pokemon_v2', '0001_squashed_0004_auto_20151005_0138'), (b'pokemon_v2', '0002_auto_20151016_0523'), (b'pokemon_v2', '0003_auto_20151022_1725'), (b'pokemon_v2', '0004_auto_20151022_1729'), (b'pokemon_v2', '0005_auto_20151022_1917'), (b'pokemon_v2', '0006_auto_20151023_0135'), (b'pokemon_v2', '0007_berry_name'), (b'pokemon_v2', '0008_auto_20151023_1735'), (b'pokemon_v2', '0009_auto_20151023_2134'), (b'pokemon_v2', '0010_auto_20151024_0252'), (b'pokemon_v2', '0011_auto_20151024_0322'), (b'pokemon_v2', '0012_auto_20151024_0340'), (b'pokemon_v2', '0013_auto_20151024_0345'), (b'pokemon_v2', '0014_auto_20151024_0350'), (b'pokemon_v2', '0015_auto_20151024_0434'), (b'pokemon_v2', '0016_auto_20151024_1942'), (b'pokemon_v2', '0017_auto_20151024_2015'), (b'pokemon_v2', '0018_auto_20151024_2021'), (b'pokemon_v2', '0019_auto_20151024_2030'), (b'pokemon_v2', '0020_auto_20151024_2200'), (b'pokemon_v2', '0021_auto_20151025_1634'), (b'pokemon_v2', '0022_auto_20151025_1725'), (b'pokemon_v2', '0023_auto_20151025_1910'), (b'pokemon_v2', '0024_auto_20151027_0023')]
|
||||
replaces = [(b'pokemon_v2', '0001_squashed_0024_auto_20151027_0023'), (b'pokemon_v2', '0002_auto_20151102_2124'), (b'pokemon_v2', '0003_auto_20151105_0309'), (b'pokemon_v2', '0004_auto_20151105_1947'), (b'pokemon_v2', '0005_auto_20151105_1949'), (b'pokemon_v2', '0006_auto_20151106_1654'), (b'pokemon_v2', '0007_auto_20151106_2319'), (b'pokemon_v2', '0008_auto_20151107_0323'), (b'pokemon_v2', '0009_auto_20151107_1516'), (b'pokemon_v2', '0010_auto_20151108_0208'), (b'pokemon_v2', '0011_auto_20151108_0352')]
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
@ -245,7 +245,6 @@ class Migration(migrations.Migration):
|
|||
name='NatureBattleStylePreference',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('move_battle_style_id', models.IntegerField()),
|
||||
('low_hp_preference', models.IntegerField()),
|
||||
('high_hp_preference', models.IntegerField()),
|
||||
('nature', models.ForeignKey(related_name='naturebattlestylepreference', blank=True, to='pokemon_v2.Nature', null=True)),
|
||||
|
@ -434,7 +433,7 @@ class Migration(migrations.Migration):
|
|||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('name', models.CharField(max_length=100)),
|
||||
('language', models.ForeignKey(related_name='movebattlestylename_language', blank=True, to='pokemon_v2.Language', null=True)),
|
||||
('move_battle_style', models.ForeignKey(blank=True, to='pokemon_v2.MoveBattleStyle', null=True)),
|
||||
('move_battle_style', models.ForeignKey(related_name='movebattlestylename', blank=True, to='pokemon_v2.MoveBattleStyle', null=True)),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
|
@ -2311,7 +2310,7 @@ class Migration(migrations.Migration):
|
|||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('name', models.CharField(max_length=100)),
|
||||
('encounter_condition_value', models.ForeignKey(blank=True, to='pokemon_v2.EncounterConditionValue', null=True)),
|
||||
('encounter_condition_value', models.ForeignKey(related_name='encounterconditionvaluename', blank=True, to='pokemon_v2.EncounterConditionValue', null=True)),
|
||||
('language', models.ForeignKey(related_name='encounterconditionvaluename_language', blank=True, to='pokemon_v2.Language', null=True)),
|
||||
],
|
||||
options={
|
||||
|
@ -2399,7 +2398,7 @@ class Migration(migrations.Migration):
|
|||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('name', models.CharField(max_length=100)),
|
||||
('language', models.ForeignKey(related_name='palparkareaname_language', blank=True, to='pokemon_v2.Language', null=True)),
|
||||
('pal_park_area', models.ForeignKey(blank=True, to='pokemon_v2.PalParkArea', null=True)),
|
||||
('pal_park_area', models.ForeignKey(related_name='palparkareaname', blank=True, to='pokemon_v2.PalParkArea', null=True)),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
|
@ -2423,7 +2422,7 @@ class Migration(migrations.Migration):
|
|||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('name', models.CharField(max_length=100)),
|
||||
('language', models.ForeignKey(related_name='pokeathlonstatname_language', blank=True, to='pokemon_v2.Language', null=True)),
|
||||
('pokeathlon_stat', models.ForeignKey(blank=True, to='pokemon_v2.PokeathlonStat', null=True)),
|
||||
('pokeathlon_stat', models.ForeignKey(related_name='pokeathlonstatname', blank=True, to='pokemon_v2.PokeathlonStat', null=True)),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
|
@ -2466,7 +2465,7 @@ class Migration(migrations.Migration):
|
|||
migrations.AddField(
|
||||
model_name='naturepokeathlonstat',
|
||||
name='pokeathlon_stat',
|
||||
field=models.ForeignKey(blank=True, to='pokemon_v2.PokeathlonStat', null=True),
|
||||
field=models.ForeignKey(related_name='naturepokeathlonstat', blank=True, to='pokemon_v2.PokeathlonStat', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
|
@ -2894,7 +2893,7 @@ class Migration(migrations.Migration):
|
|||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('effect', models.CharField(max_length=4000)),
|
||||
('ability_change', models.ForeignKey(blank=True, to='pokemon_v2.AbilityChange', null=True)),
|
||||
('ability_change', models.ForeignKey(related_name='abilitychangeeffecttext', blank=True, to='pokemon_v2.AbilityChange', null=True)),
|
||||
('language', models.ForeignKey(related_name='abilitychangeeffecttext_language', blank=True, to='pokemon_v2.Language', null=True)),
|
||||
],
|
||||
options={
|
||||
|
@ -2949,7 +2948,7 @@ class Migration(migrations.Migration):
|
|||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('effect', models.CharField(max_length=4000)),
|
||||
('language', models.ForeignKey(related_name='moveeffectchangeeffecttext_language', blank=True, to='pokemon_v2.Language', null=True)),
|
||||
('move_effect_change', models.ForeignKey(blank=True, to='pokemon_v2.MoveEffectChange', null=True)),
|
||||
('move_effect_change', models.ForeignKey(related_name='moveeffectchangeeffecttext', blank=True, to='pokemon_v2.MoveEffectChange', null=True)),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
|
@ -2976,7 +2975,7 @@ class Migration(migrations.Migration):
|
|||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('flavor_text', models.CharField(max_length=500)),
|
||||
('language', models.ForeignKey(related_name='supercontesteffectflavortext_language', blank=True, to='pokemon_v2.Language', null=True)),
|
||||
('super_contest_effect', models.ForeignKey(blank=True, to='pokemon_v2.SuperContestEffect', null=True)),
|
||||
('super_contest_effect', models.ForeignKey(related_name='supercontesteffectflavortext', blank=True, to='pokemon_v2.SuperContestEffect', null=True)),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
|
@ -3036,4 +3035,22 @@ class Migration(migrations.Migration):
|
|||
field=models.ForeignKey(blank=True, to='pokemon_v2.PokemonShape', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='berryflavor',
|
||||
name='berry',
|
||||
field=models.ForeignKey(related_name='berryflavor', blank=True, to='pokemon_v2.Berry', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='naturebattlestylepreference',
|
||||
name='move_battle_style',
|
||||
field=models.ForeignKey(related_name='naturebattlestylepreference', blank=True, to='pokemon_v2.MoveBattleStyle', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='abilitychange',
|
||||
name='version_group',
|
||||
field=models.ForeignKey(related_name='abilitychange', blank=True, to='pokemon_v2.VersionGroup', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
|
@ -1,20 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pokemon_v2', '0001_squashed_0024_auto_20151027_0023'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='encounterconditionvaluename',
|
||||
name='encounter_condition_value',
|
||||
field=models.ForeignKey(related_name='encounterconditionvaluename', blank=True, to='pokemon_v2.EncounterConditionValue', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
|
@ -1,20 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pokemon_v2', '0002_auto_20151102_2124'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='supercontesteffectflavortext',
|
||||
name='super_contest_effect',
|
||||
field=models.ForeignKey(related_name='supercontesteffectflavortext', blank=True, to='pokemon_v2.SuperContestEffect', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
|
@ -264,7 +264,7 @@ class HasOrder(models.Model):
|
|||
|
||||
class HasPokeathlonStat(models.Model):
|
||||
|
||||
pokeathlon_stat = models.ForeignKey('PokeathlonStat', blank=True, null=True)
|
||||
pokeathlon_stat = models.ForeignKey('PokeathlonStat', blank=True, null=True, related_name="%(class)s")
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
@ -492,13 +492,13 @@ class AbilityName(IsName, HasAbility):
|
|||
pass
|
||||
|
||||
|
||||
class AbilityChange(HasAbility):
|
||||
class AbilityChange(HasAbility, HasVersionGroup):
|
||||
pass
|
||||
|
||||
|
||||
class AbilityChangeEffectText(HasLanguage, HasEffect):
|
||||
|
||||
ability_change = models.ForeignKey(AbilityChange, blank=True, null=True)
|
||||
ability_change = models.ForeignKey(AbilityChange, blank=True, null=True, related_name="%(class)s")
|
||||
|
||||
|
||||
|
||||
|
@ -711,7 +711,7 @@ class Berry(HasName, HasItem, HasNature):
|
|||
|
||||
class BerryFlavor(HasContestType):
|
||||
|
||||
berry = models.ForeignKey(Berry, blank=True, null=True)
|
||||
berry = models.ForeignKey(Berry, blank=True, null=True, related_name="%(class)s")
|
||||
|
||||
flavor = models.IntegerField()
|
||||
|
||||
|
@ -759,7 +759,7 @@ class NaturePokeathlonStat(HasNature, HasPokeathlonStat):
|
|||
|
||||
class NatureBattleStylePreference(HasNature):
|
||||
|
||||
move_battle_style_id = models.IntegerField()
|
||||
move_battle_style = models.ForeignKey('MoveBattleStyle', blank = True, null = True, related_name="%(class)s")
|
||||
|
||||
low_hp_preference = models.IntegerField()
|
||||
|
||||
|
@ -919,7 +919,7 @@ class MoveBattleStyle(HasName):
|
|||
|
||||
class MoveBattleStyleName(IsName):
|
||||
|
||||
move_battle_style = models.ForeignKey(MoveBattleStyle, blank = True, null = True)
|
||||
move_battle_style = models.ForeignKey(MoveBattleStyle, blank = True, null = True, related_name="%(class)s")
|
||||
|
||||
|
||||
|
||||
|
@ -941,7 +941,7 @@ class MoveEffectChange(HasMoveEffect, HasVersionGroup):
|
|||
|
||||
class MoveEffectChangeEffectText(HasLanguage, HasEffect):
|
||||
|
||||
move_effect_change = models.ForeignKey('MoveEffectChange', blank = True, null = True)
|
||||
move_effect_change = models.ForeignKey('MoveEffectChange', blank = True, null = True, related_name="%(class)s")
|
||||
|
||||
|
||||
|
||||
|
@ -1092,7 +1092,7 @@ class PalParkArea(HasName):
|
|||
|
||||
class PalParkAreaName(IsName):
|
||||
|
||||
pal_park_area = models.ForeignKey(PalParkArea, blank = True, null = True)
|
||||
pal_park_area = models.ForeignKey(PalParkArea, blank = True, null = True, related_name="%(class)s")
|
||||
|
||||
|
||||
class PalPark(HasPokemonSpecies):
|
||||
|
|
|
@ -97,6 +97,12 @@ class GenerationSummarySerializer(serializers.HyperlinkedModelSerializer):
|
|||
model = Generation
|
||||
fields = ('name', 'url')
|
||||
|
||||
class GenderSummarySerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Gender
|
||||
fields = ('name', 'url')
|
||||
|
||||
class GrowthRateSummarySerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
|
@ -151,6 +157,18 @@ class LocationAreaSummarySerializer(serializers.HyperlinkedModelSerializer):
|
|||
model = LocationArea
|
||||
fields = ('name', 'url')
|
||||
|
||||
class MachineSummarySerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Machine
|
||||
fields = ('url',)
|
||||
|
||||
class MoveBattleStyleSummarySerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = MoveBattleStyle
|
||||
fields = ('name', 'url')
|
||||
|
||||
class MoveDamageClassSummarySerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
|
@ -193,6 +211,18 @@ class NatureSummarySerializer(serializers.HyperlinkedModelSerializer):
|
|||
model = Nature
|
||||
fields = ('name', 'url')
|
||||
|
||||
class PalParkAreaSummarySerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = PalParkArea
|
||||
fields = ('name', 'url')
|
||||
|
||||
class PokeathlonStatSummarySerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = PokeathlonStat
|
||||
fields = ('name', 'url')
|
||||
|
||||
class PokedexSummarySerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
|
@ -285,6 +315,16 @@ class ItemAttributeMapSerializer(serializers.ModelSerializer):
|
|||
model = ItemAttributeMap
|
||||
fields = ('item', 'attribute',)
|
||||
|
||||
class VersionGroupMoveLearnMethodSerializer(serializers.ModelSerializer):
|
||||
|
||||
version_group = VersionGroupSummarySerializer()
|
||||
move_learn_method = MoveLearnMethodSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = ItemAttributeMap
|
||||
fields = ('version_group', 'move_learn_method')
|
||||
|
||||
|
||||
class VersionGroupRegionSerializer(serializers.ModelSerializer):
|
||||
|
||||
version_group = VersionGroupSummarySerializer()
|
||||
|
@ -475,6 +515,17 @@ class GenerationDetailSerializer(serializers.ModelSerializer):
|
|||
|
||||
|
||||
|
||||
########################
|
||||
# GENDER SERIALIZERS #
|
||||
########################
|
||||
|
||||
class GenderDetailSerializer(serializers.ModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Gender
|
||||
|
||||
|
||||
|
||||
#############################
|
||||
# GROWTH RATE SERIALIZERS #
|
||||
#############################
|
||||
|
@ -740,6 +791,14 @@ class LocationAreaDetailSerializer(serializers.ModelSerializer):
|
|||
return encounters_list
|
||||
|
||||
|
||||
class LocationGameIndexSerializer(serializers.ModelSerializer):
|
||||
|
||||
generation = GenerationSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = LocationGameIndex
|
||||
fields = ('game_index', 'generation')
|
||||
|
||||
|
||||
class LocationNameSerializer(serializers.ModelSerializer):
|
||||
|
||||
|
@ -754,11 +813,12 @@ class LocationDetailSerializer(serializers.ModelSerializer):
|
|||
|
||||
region = RegionSummarySerializer()
|
||||
names = LocationNameSerializer(many=True, read_only=True, source="locationname")
|
||||
game_indices = LocationGameIndexSerializer(many=True, read_only=True, source="locationgameindex")
|
||||
areas = LocationAreaSummarySerializer(many=True, read_only=True, source="locationarea")
|
||||
|
||||
class Meta:
|
||||
model = Location
|
||||
fields = ('id', 'name', 'region', 'names', 'areas')
|
||||
fields = ('id', 'name', 'region', 'names', 'game_indices', 'areas')
|
||||
|
||||
|
||||
|
||||
|
@ -786,6 +846,25 @@ class AbilityFlavorTextSerializer(serializers.ModelSerializer):
|
|||
fields = ('text', 'version_group', 'language')
|
||||
|
||||
|
||||
class AbilityChangeEffectTextSerializer(serializers.ModelSerializer):
|
||||
|
||||
language = LanguageSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = AbilityChangeEffectText
|
||||
fields = ('effect', 'language',)
|
||||
|
||||
|
||||
class AbilityChangeSerializer(serializers.ModelSerializer):
|
||||
|
||||
version_group = VersionGroupSummarySerializer()
|
||||
effect_text_entries = AbilityChangeEffectTextSerializer(many=True, read_only=True, source="abilitychangeeffecttext")
|
||||
|
||||
class Meta:
|
||||
model = AbilityChange
|
||||
fields = ('version_group', 'effect_text_entries')
|
||||
|
||||
|
||||
class AbilityNameSerializer(serializers.ModelSerializer):
|
||||
|
||||
language = LanguageSummarySerializer()
|
||||
|
@ -801,6 +880,7 @@ class AbilityDetailSerializer(serializers.ModelSerializer):
|
|||
flavor_text_entries = AbilityFlavorTextSerializer(many=True, read_only=True, source="abilityflavortext")
|
||||
names = AbilityNameSerializer(many=True, read_only=True, source="abilityname")
|
||||
generation = GenerationSummarySerializer()
|
||||
changes = AbilityChangeSerializer(many=True, read_only=True, source="abilitychange")
|
||||
|
||||
class Meta:
|
||||
model = Ability
|
||||
|
@ -811,7 +891,8 @@ class AbilityDetailSerializer(serializers.ModelSerializer):
|
|||
'generation',
|
||||
'names',
|
||||
'effect_text_entries',
|
||||
'flavor_text_entries'
|
||||
'flavor_text_entries',
|
||||
'changes'
|
||||
)
|
||||
|
||||
|
||||
|
@ -966,6 +1047,15 @@ class ItemEffectTextSerializer(serializers.ModelSerializer):
|
|||
fields = ('effect', 'short_effect', 'language')
|
||||
|
||||
|
||||
class ItemGameIndexSerializer(serializers.ModelSerializer):
|
||||
|
||||
generation = GenerationSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = ItemGameIndex
|
||||
fields = ('game_index', 'generation')
|
||||
|
||||
|
||||
class ItemNameSerializer(serializers.ModelSerializer):
|
||||
|
||||
language = LanguageSummarySerializer()
|
||||
|
@ -978,6 +1068,7 @@ class ItemNameSerializer(serializers.ModelSerializer):
|
|||
class ItemDetailSerializer(serializers.ModelSerializer):
|
||||
|
||||
names = ItemNameSerializer(many=True, read_only=True, source="itemname")
|
||||
game_indices = ItemGameIndexSerializer(many=True, read_only=True, source="itemgameindex")
|
||||
effect_text_entries = ItemEffectTextSerializer(many=True, read_only=True, source="itemeffecttext")
|
||||
flavor_text_entries = ItemFlavorTextSerializer(many=True, read_only=True, source="itemflavortext")
|
||||
category = ItemCategorySummarySerializer(source="item_category")
|
||||
|
@ -995,6 +1086,7 @@ class ItemDetailSerializer(serializers.ModelSerializer):
|
|||
'category',
|
||||
'attributes',
|
||||
'names',
|
||||
'game_indices',
|
||||
'effect_text_entries',
|
||||
'flavor_text_entries',
|
||||
)
|
||||
|
@ -1021,6 +1113,24 @@ class ItemDetailSerializer(serializers.ModelSerializer):
|
|||
# NATURE SERIALIZERS #
|
||||
########################
|
||||
|
||||
class NatureBattleStylePreferenceSerializer(serializers.ModelSerializer):
|
||||
|
||||
move_battle_style = MoveBattleStyleSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = NatureBattleStylePreference
|
||||
fields = ( 'low_hp_preference', 'high_hp_preference', 'move_battle_style',)
|
||||
|
||||
|
||||
class NaturePokeathlonStatSerializer(serializers.ModelSerializer):
|
||||
|
||||
pokeathlon_stat = PokeathlonStatSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = NaturePokeathlonStat
|
||||
fields = ( 'max_change', 'pokeathlon_stat',)
|
||||
|
||||
|
||||
class NatureNameSerializer(serializers.ModelSerializer):
|
||||
|
||||
language = LanguageSummarySerializer()
|
||||
|
@ -1037,10 +1147,12 @@ class NatureDetailSerializer(serializers.ModelSerializer):
|
|||
names = NatureNameSerializer(many=True, read_only=True, source="naturename")
|
||||
decreased_stat = StatSummarySerializer()
|
||||
increased_stat = StatSummarySerializer()
|
||||
pokeathlon_stat_changes = NaturePokeathlonStatSerializer(many=True, read_only=True, source="naturepokeathlonstat")
|
||||
move_battle_style_preferences = NatureBattleStylePreferenceSerializer(many=True, read_only=True, source="naturebattlestylepreference")
|
||||
|
||||
class Meta:
|
||||
model = Nature
|
||||
fields = ('id', 'name', 'names', 'decreased_stat', 'increased_stat')
|
||||
fields = ('id', 'name', 'decreased_stat', 'increased_stat', 'pokeathlon_stat_changes', 'move_battle_style_preferences', 'names')
|
||||
|
||||
|
||||
|
||||
|
@ -1066,12 +1178,23 @@ class BerryFirmnessDetailSerializer(serializers.ModelSerializer):
|
|||
fields = ('id', 'name', 'names')
|
||||
|
||||
|
||||
class BerryFlavorSerializer(serializers.ModelSerializer):
|
||||
|
||||
contest_type = ContestTypeSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = BerryFlavor
|
||||
fields = ('flavor', 'contest_type')
|
||||
|
||||
|
||||
class BerryDetailSerializer(serializers.ModelSerializer):
|
||||
|
||||
item = ItemSummarySerializer()
|
||||
nature = NatureSummarySerializer()
|
||||
nature_power = serializers.IntegerField(source='natural_gift_power')
|
||||
firmness = BerryFirmnessSummarySerializer(source="berry_firmness")
|
||||
# flavors = BerryFlavorSerializer(many=True, read_only=True, source="berryflavor")
|
||||
flavors = serializers.SerializerMethodField('get_flavor_strengths')
|
||||
|
||||
class Meta:
|
||||
model = Berry
|
||||
|
@ -1086,9 +1209,38 @@ class BerryDetailSerializer(serializers.ModelSerializer):
|
|||
'nature_power',
|
||||
'size',
|
||||
'smoothness',
|
||||
'soil_dryness'
|
||||
'soil_dryness',
|
||||
'flavors'
|
||||
)
|
||||
|
||||
def get_flavor_strengths(self, obj):
|
||||
|
||||
"""
|
||||
I'm not super proud of how this is being done but the data for berry
|
||||
flavors and how they map to contest types is very wonky in my opinion.
|
||||
Something worth suggesting a change for in veekun's data set.
|
||||
Shoot me.
|
||||
"""
|
||||
|
||||
flavor_objects = BerryFlavor.objects.filter(berry=obj)
|
||||
|
||||
flavors = OrderedDict()
|
||||
|
||||
for flavor_obj in flavor_objects:
|
||||
|
||||
contest_type_obj = ContestType.objects.get(pk=flavor_obj.contest_type.id)
|
||||
contest_type = ContestTypeDetailSerializer(contest_type_obj, context=self.context).data
|
||||
flavor = BerryFlavorSerializer(flavor_obj, context=self.context).data
|
||||
|
||||
for contest_type_name in contest_type['names']:
|
||||
if contest_type_name['language']['name'] == 'en':
|
||||
|
||||
dict = flavors[contest_type['names'][0]['flavor'].lower()] = OrderedDict()
|
||||
dict['strength'] = flavor['flavor']
|
||||
dict['contest_type'] = flavor['contest_type']
|
||||
|
||||
return flavors
|
||||
|
||||
|
||||
|
||||
###########################
|
||||
|
@ -1145,6 +1297,15 @@ class TypeEfficacySerializer(serializers.ModelSerializer):
|
|||
model = TypeEfficacy
|
||||
|
||||
|
||||
class TypeGameIndexSerializer(serializers.ModelSerializer):
|
||||
|
||||
generation = GenerationSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = TypeGameIndex
|
||||
fields = ('game_index', 'generation')
|
||||
|
||||
|
||||
class TypeNameSerializer(serializers.ModelSerializer):
|
||||
|
||||
language = LanguageSummarySerializer()
|
||||
|
@ -1160,12 +1321,13 @@ class TypeDetailSerializer(serializers.ModelSerializer):
|
|||
"""
|
||||
generation = GenerationSummarySerializer()
|
||||
names = AbilityNameSerializer(many=True, read_only=True, source="typename")
|
||||
game_indices = TypeGameIndexSerializer(many=True, read_only=True, source="typegameindex")
|
||||
move_damage_class = MoveDamageClassSummarySerializer()
|
||||
damage_relations = serializers.SerializerMethodField('get_type_relationships')
|
||||
|
||||
class Meta:
|
||||
model = Type
|
||||
fields = ('id', 'name', 'move_damage_class', 'generation', 'names', 'damage_relations')
|
||||
fields = ('id', 'name', 'move_damage_class', 'generation', 'names', 'game_indices', 'damage_relations')
|
||||
|
||||
def get_type_relationships(self, obj):
|
||||
|
||||
|
@ -1208,6 +1370,45 @@ class TypeDetailSerializer(serializers.ModelSerializer):
|
|||
|
||||
|
||||
|
||||
#########################
|
||||
# MACHINE SERIALIZERS #
|
||||
#########################
|
||||
|
||||
class MachineDetailSerializer(serializers.ModelSerializer):
|
||||
|
||||
item = ItemSummarySerializer()
|
||||
version_group = VersionSummarySerializer()
|
||||
move = MoveSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = Machine
|
||||
fields = ('id', 'item', 'version_group', 'move')
|
||||
|
||||
|
||||
###################################
|
||||
# MOVE BATTLE STYLE SERIALIZERS #
|
||||
###################################
|
||||
|
||||
class MoveBattleStyleNameSerializer(serializers.ModelSerializer):
|
||||
|
||||
language = LanguageSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = MoveBattleStyleName
|
||||
fields = ('name', 'language')
|
||||
|
||||
|
||||
class MoveBattleStyleDetailSerializer(serializers.ModelSerializer):
|
||||
|
||||
names = MoveBattleStyleNameSerializer(many=True, read_only=True, source="movebattlestylename")
|
||||
|
||||
class Meta:
|
||||
model = MoveBattleStyle
|
||||
fields = ('id', 'name', 'names')
|
||||
|
||||
|
||||
|
||||
|
||||
###################################
|
||||
# MOVE DAMAGE CLASS SERIALIZERS #
|
||||
###################################
|
||||
|
@ -1281,6 +1482,15 @@ class MoveMetaCategoryDetailSerializer(serializers.ModelSerializer):
|
|||
fields = ('id', 'name', 'descriptions')
|
||||
|
||||
|
||||
class MoveMetaStatChangeSerializer(serializers.ModelSerializer):
|
||||
|
||||
stat = StatSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = MoveMetaStatChange
|
||||
fields = ('change', 'stat')
|
||||
|
||||
|
||||
class MoveMetaSerializer(serializers.ModelSerializer):
|
||||
|
||||
ailment = MoveMetaAilmentSummarySerializer(source="move_meta_ailment")
|
||||
|
@ -1302,7 +1512,7 @@ class MoveMetaSerializer(serializers.ModelSerializer):
|
|||
'flinch_chance',
|
||||
'stat_chance'
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
#############################
|
||||
|
@ -1351,6 +1561,45 @@ class MoveNameSerializer(serializers.ModelSerializer):
|
|||
fields = ('name', 'language')
|
||||
|
||||
|
||||
class MoveChangeSerializer(serializers.ModelSerializer):
|
||||
|
||||
version_group = VersionGroupSummarySerializer()
|
||||
type = TypeSummarySerializer()
|
||||
effect_chance = serializers.IntegerField(source='move_effect_chance')
|
||||
|
||||
class Meta:
|
||||
model = MoveChange
|
||||
fields = ('accuracy', 'power', 'pp', 'effect_chance', 'type', 'version_group',)
|
||||
|
||||
|
||||
class MoveEffectEffectTextSerializer(serializers.ModelSerializer):
|
||||
|
||||
language = LanguageSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = MoveEffectEffectText
|
||||
fields = ('effect', 'short_effect', 'language')
|
||||
|
||||
|
||||
class MoveEffectChangeEffectTextSerializer(serializers.ModelSerializer):
|
||||
|
||||
language = LanguageSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = MoveEffectChangeEffectText
|
||||
fields = ('effect', 'language')
|
||||
|
||||
|
||||
class MoveEffectChangeSerializer(serializers.ModelSerializer):
|
||||
|
||||
version_group = VersionGroupSummarySerializer()
|
||||
effect_text_entries = MoveEffectChangeEffectTextSerializer(many=True, read_only=True, source="moveeffectchangeeffecttext")
|
||||
|
||||
class Meta:
|
||||
model = MoveEffectChange
|
||||
fields = ('version_group', 'effect_text_entries')
|
||||
|
||||
|
||||
class MoveDetailSerializer(serializers.ModelSerializer):
|
||||
|
||||
generation = GenerationSummarySerializer()
|
||||
|
@ -1359,9 +1608,12 @@ class MoveDetailSerializer(serializers.ModelSerializer):
|
|||
damage_class = MoveDamageClassSummarySerializer(source="move_damage_class")
|
||||
meta = MoveMetaSerializer(read_only=True, source="movemeta")
|
||||
names = MoveNameSerializer(many=True, read_only=True, source="movename")
|
||||
effect_text_entries = serializers.SerializerMethodField('get_effect_entries')
|
||||
effect_chance = serializers.IntegerField(source="move_effect_chance")
|
||||
contest_combo_detail = serializers.SerializerMethodField('get_contest_combos')
|
||||
# super_contest_combo_detail = serializers.SerializerMethodField('get_super_contest_combos')
|
||||
stat_changes = MoveMetaStatChangeSerializer(many=True, read_only=True, source="movemetastatchange")
|
||||
changes = MoveChangeSerializer(many=True, read_only=True, source="movechange")
|
||||
effect_changes = serializers.SerializerMethodField('get_effect_change_entries')
|
||||
|
||||
class Meta:
|
||||
model = Move
|
||||
|
@ -1369,18 +1621,21 @@ class MoveDetailSerializer(serializers.ModelSerializer):
|
|||
'id',
|
||||
'name',
|
||||
'accuracy',
|
||||
'damage_class',
|
||||
'pp',
|
||||
'priority',
|
||||
'power',
|
||||
'effect_text_entries',
|
||||
'effect_chance',
|
||||
'damage_class',
|
||||
'generation',
|
||||
'meta',
|
||||
'target',
|
||||
'names',
|
||||
'power',
|
||||
'pp',
|
||||
'priority',
|
||||
'type',
|
||||
'stat_changes',
|
||||
'contest_combo_detail',
|
||||
# 'super_contest_combo_detail'
|
||||
'changes',
|
||||
'effect_changes'
|
||||
)
|
||||
|
||||
def get_contest_combos(self, obj):
|
||||
|
@ -1395,54 +1650,84 @@ class MoveDetailSerializer(serializers.ModelSerializer):
|
|||
super_after_objects = SuperContestCombo.objects.filter(second_move=obj)
|
||||
super_after_data = SuperContestComboSerializer(super_after_objects, many=True, context=self.context).data
|
||||
|
||||
details = OrderedDict()
|
||||
details['normal'] = OrderedDict()
|
||||
details['normal']['use_before'] = None
|
||||
details['normal']['use_after'] = None
|
||||
details['super'] = OrderedDict()
|
||||
details['super']['use_before'] = None
|
||||
details['super']['use_after'] = None
|
||||
details = None
|
||||
|
||||
for combo in normal_before_data:
|
||||
if details['normal']['use_before'] == None:
|
||||
details['normal']['use_before'] = []
|
||||
details['normal']['use_before'].append(combo['second_move'])
|
||||
if normal_before_data or normal_after_data or super_before_data or super_after_data:
|
||||
|
||||
for combo in normal_after_data:
|
||||
if details['normal']['use_after'] == None:
|
||||
details['normal']['use_after'] = []
|
||||
details['normal']['use_after'].append(combo['first_move'])
|
||||
details = OrderedDict()
|
||||
details['normal'] = OrderedDict()
|
||||
details['normal']['use_before'] = None
|
||||
details['normal']['use_after'] = None
|
||||
details['super'] = OrderedDict()
|
||||
details['super']['use_before'] = None
|
||||
details['super']['use_after'] = None
|
||||
|
||||
for combo in super_before_data:
|
||||
if details['super']['use_before'] == None:
|
||||
details['super']['use_before'] = []
|
||||
details['super']['use_before'].append(combo['second_move'])
|
||||
for combo in normal_before_data:
|
||||
if details['normal']['use_before'] == None:
|
||||
details['normal']['use_before'] = []
|
||||
details['normal']['use_before'].append(combo['second_move'])
|
||||
|
||||
for combo in super_after_data:
|
||||
if details['super']['use_after'] == None:
|
||||
details['super']['use_after'] = []
|
||||
details['super']['use_after'].append(combo['first_move'])
|
||||
for combo in normal_after_data:
|
||||
if details['normal']['use_after'] == None:
|
||||
details['normal']['use_after'] = []
|
||||
details['normal']['use_after'].append(combo['first_move'])
|
||||
|
||||
for combo in super_before_data:
|
||||
if details['super']['use_before'] == None:
|
||||
details['super']['use_before'] = []
|
||||
details['super']['use_before'].append(combo['second_move'])
|
||||
|
||||
for combo in super_after_data:
|
||||
if details['super']['use_after'] == None:
|
||||
details['super']['use_after'] = []
|
||||
details['super']['use_after'].append(combo['first_move'])
|
||||
|
||||
return details
|
||||
|
||||
# def get_super_contest_combos(self, obj):
|
||||
def get_effect_entries(self, obj):
|
||||
|
||||
# before_objects = SuperContestCombo.objects.filter(first_move=obj)
|
||||
# before_data = SuperContestComboSerializer(before_objects, many=True, context=self.context).data
|
||||
# after_objects = SuperContestCombo.objects.filter(second_move=obj)
|
||||
# after_data = SuperContestComboSerializer(after_objects, many=True, context=self.context).data
|
||||
effect_texts = MoveEffectEffectText.objects.filter(move_effect=obj.move_effect)
|
||||
data = MoveEffectEffectTextSerializer(effect_texts, many=True, context=self.context).data
|
||||
|
||||
# details = OrderedDict()
|
||||
# details['use_before'] = []
|
||||
# details['use_after'] = []
|
||||
return data
|
||||
|
||||
# for combo in before_data:
|
||||
# details['use_before'].append(combo['second_move'])
|
||||
def get_effect_change_entries(self, obj):
|
||||
|
||||
# for combo in after_data:
|
||||
# details['use_after'].append(combo['first_move'])
|
||||
effect_changes = MoveEffectChange.objects.filter(move_effect=obj.move_effect)
|
||||
data = MoveEffectChangeSerializer(effect_changes, many=True, context=self.context).data
|
||||
|
||||
# return details
|
||||
return data
|
||||
|
||||
|
||||
##########################
|
||||
# PAL PARK SERIALIZERS #
|
||||
##########################
|
||||
|
||||
class PalParkAreaNameSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
language = LanguageSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = PalParkAreaName
|
||||
fields = ('name', 'language')
|
||||
|
||||
|
||||
class PalParkAreaDetailSerializer(serializers.ModelSerializer):
|
||||
|
||||
names = PalParkAreaNameSerializer(many=True, read_only=True, source="palparkareaname")
|
||||
|
||||
class Meta:
|
||||
model = PalParkArea
|
||||
fields = ('id', 'name', 'names')
|
||||
|
||||
|
||||
class PalParkSerializer(serializers.ModelSerializer):
|
||||
|
||||
area = PalParkAreaSummarySerializer(read_only=True, source="pal_park_area")
|
||||
|
||||
class Meta:
|
||||
model = PalPark
|
||||
fields = ('base_score', 'rate', 'area')
|
||||
|
||||
|
||||
|
||||
|
@ -1557,11 +1842,22 @@ class MoveLearnMethodDetailSerializer(serializers.ModelSerializer):
|
|||
|
||||
names = MoveLearnMethodNameSerializer(many=True, read_only=True, source="movelearnmethodname")
|
||||
descriptions = MoveLearnMethodDescriptionSerializer(many=True, read_only=True, source="movelearnmethoddescription")
|
||||
version_groups = serializers.SerializerMethodField('get_method_version_groups')
|
||||
|
||||
class Meta:
|
||||
model = MoveLearnMethod
|
||||
fields = ('id', 'name', 'names', 'descriptions')
|
||||
fields = ('id', 'name', 'names', 'descriptions', 'version_groups')
|
||||
|
||||
def get_method_version_groups(self,obj):
|
||||
|
||||
version_group_objects = VersionGroupMoveLearnMethod.objects.filter(move_learn_method=obj)
|
||||
version_group_data = VersionGroupMoveLearnMethodSerializer(version_group_objects, many=True, context=self.context).data
|
||||
groups = []
|
||||
|
||||
for vg in version_group_data:
|
||||
groups.append(vg['version_group'])
|
||||
|
||||
return groups
|
||||
|
||||
|
||||
class PokemonMoveSerializer(serializers.ModelSerializer):
|
||||
|
@ -1667,9 +1963,18 @@ class PokemonTypeSerializer(serializers.ModelSerializer):
|
|||
# POKEMON SERIALIZERS #
|
||||
#########################
|
||||
|
||||
class PokemonGameIndexSerializer(serializers.ModelSerializer):
|
||||
|
||||
version = VersionSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = PokemonGameIndex
|
||||
fields = ('game_index', 'version')
|
||||
|
||||
class PokemonDetailSerializer(serializers.ModelSerializer):
|
||||
|
||||
abilities = PokemonAbilitySerializer(many=True, read_only=True, source="pokemonability")
|
||||
game_indices = PokemonGameIndexSerializer(many=True, read_only=True, source="pokemongameindex")
|
||||
moves = serializers.SerializerMethodField('get_pokemon_moves')
|
||||
species = PokemonSpeciesSummarySerializer(source="pokemon_species")
|
||||
stats = PokemonStatSerializer(many=True, read_only=True, source="pokemonstat")
|
||||
|
@ -1696,6 +2001,7 @@ class PokemonDetailSerializer(serializers.ModelSerializer):
|
|||
'forms',
|
||||
'held_items',
|
||||
'moves',
|
||||
'game_indices',
|
||||
'location_areas'
|
||||
)
|
||||
|
||||
|
@ -1880,6 +2186,15 @@ class PokemonDexEntrySerializer(serializers.ModelSerializer):
|
|||
fields = ('entry_number', 'pokedex')
|
||||
|
||||
|
||||
class PokemonSpeciesDescriptionSerializer(serializers.ModelSerializer):
|
||||
|
||||
language = LanguageSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = PokemonSpeciesDescription
|
||||
fields = ('description', 'language')
|
||||
|
||||
|
||||
class PokemonSpeciesNameSerializer(serializers.ModelSerializer):
|
||||
|
||||
language = LanguageSummarySerializer()
|
||||
|
@ -1902,6 +2217,7 @@ class PokemonSpeciesEvolutionSerializer(serializers.ModelSerializer):
|
|||
class PokemonSpeciesDetailSerializer(serializers.ModelSerializer):
|
||||
|
||||
names = serializers.SerializerMethodField('get_pokemon_names')
|
||||
form_descriptions = PokemonSpeciesDescriptionSerializer(many=True, read_only=True, source="pokemonspeciesdescription")
|
||||
pokedex_numbers = PokemonDexEntrySerializer(many=True, read_only=True, source="pokemondexnumber")
|
||||
egg_groups = serializers.SerializerMethodField('get_pokemon_egg_groups')
|
||||
genera = serializers.SerializerMethodField('get_pokemon_genera')
|
||||
|
@ -1914,6 +2230,7 @@ class PokemonSpeciesDetailSerializer(serializers.ModelSerializer):
|
|||
varieties = PokemonSummarySerializer(many=True, read_only=True, source="pokemon")
|
||||
varieties = serializers.SerializerMethodField('get_pokemon_varieties')
|
||||
evolution_chain = EvolutionChainSummarySerializer()
|
||||
pal_park_encounter = PalParkSerializer(many=True, read_only=True, source="palpark")
|
||||
|
||||
class Meta:
|
||||
model = PokemonSpecies
|
||||
|
@ -1938,6 +2255,8 @@ class PokemonSpeciesDetailSerializer(serializers.ModelSerializer):
|
|||
'habitat',
|
||||
'generation',
|
||||
'names',
|
||||
'pal_park_encounter',
|
||||
'form_descriptions',
|
||||
'genera',
|
||||
'varieties'
|
||||
)
|
||||
|
@ -2101,6 +2420,29 @@ class PokemonDexNumberSerializer(serializers.ModelSerializer):
|
|||
|
||||
|
||||
|
||||
############################
|
||||
# POKEATHLON SERIALIZERS #
|
||||
############################
|
||||
|
||||
class PokeathlonStatNameSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
language = LanguageSummarySerializer()
|
||||
|
||||
class Meta:
|
||||
model = PokeathlonStatName
|
||||
fields = ('name', 'language')
|
||||
|
||||
|
||||
class PokeathlonStatDetailSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
names = PokeathlonStatNameSerializer(many=True, read_only=True, source="pokeathlonstatname")
|
||||
|
||||
class Meta:
|
||||
model = PokeathlonStat
|
||||
fields = ('id', 'name', 'names')
|
||||
|
||||
|
||||
|
||||
#########################
|
||||
# POKEDEX SERIALIZERS #
|
||||
#########################
|
||||
|
@ -2185,10 +2527,11 @@ class VersionGroupDetailSerializer(serializers.ModelSerializer):
|
|||
generation = GenerationSummarySerializer()
|
||||
versions = VersionSummarySerializer(many=True, read_only=True, source="version")
|
||||
regions = serializers.SerializerMethodField('get_version_group_regions')
|
||||
move_learn_methods = serializers.SerializerMethodField('get_learn_methods')
|
||||
|
||||
class Meta:
|
||||
model = VersionGroup
|
||||
fields = ('id', 'name', 'order', 'generation', 'versions', 'regions')
|
||||
fields = ('id', 'name', 'order', 'generation', 'versions', 'regions', 'move_learn_methods')
|
||||
|
||||
def get_version_group_regions(self, obj):
|
||||
|
||||
|
@ -2200,3 +2543,14 @@ class VersionGroupDetailSerializer(serializers.ModelSerializer):
|
|||
regions.append(region['region'])
|
||||
|
||||
return regions
|
||||
|
||||
def get_learn_methods(self,obj):
|
||||
|
||||
learn_method_objects = VersionGroupMoveLearnMethod.objects.filter(version_group=obj)
|
||||
learn_method_data = VersionGroupMoveLearnMethodSerializer(learn_method_objects, many=True, context=self.context).data
|
||||
methods = []
|
||||
|
||||
for method in learn_method_data:
|
||||
methods.append(method['move_learn_method'])
|
||||
|
||||
return methods
|
||||
|
|
|
@ -66,6 +66,13 @@ class AbilityResource(PokeapiCommonViewset):
|
|||
list_serializer_class = AbilitySummarySerializer
|
||||
|
||||
|
||||
class AbilityChangeResource(PokeapiCommonViewset):
|
||||
|
||||
queryset = AbilityChange.objects.all()
|
||||
serializer_class = AbilityChangeSerializer
|
||||
list_serializer_class = AbilityChangeSerializer
|
||||
|
||||
|
||||
class BerryResource(PokeapiCommonViewset):
|
||||
|
||||
queryset = Berry.objects.all()
|
||||
|
@ -150,6 +157,13 @@ class GenerationResource(PokeapiCommonViewset):
|
|||
list_serializer_class = GenerationSummarySerializer
|
||||
|
||||
|
||||
class GenderResource(PokeapiCommonViewset):
|
||||
|
||||
queryset = Gender.objects.all()
|
||||
serializer_class = GenderDetailSerializer
|
||||
list_serializer_class = GenderSummarySerializer
|
||||
|
||||
|
||||
class GrowthRateResource(PokeapiCommonViewset):
|
||||
|
||||
queryset = GrowthRate.objects.all()
|
||||
|
@ -213,6 +227,13 @@ class LocationAreaResource(PokeapiCommonViewset):
|
|||
list_serializer_class = LocationAreaSummarySerializer
|
||||
|
||||
|
||||
# class MachineResource(PokeapiCommonViewset):
|
||||
|
||||
# queryset = Machine.objects.all()
|
||||
# serializer_class = MachineDetailSerializer
|
||||
# list_serializer_class = MachineSummarySerializer
|
||||
|
||||
|
||||
class MoveResource(PokeapiCommonViewset):
|
||||
|
||||
queryset = Move.objects.all()
|
||||
|
@ -234,6 +255,13 @@ class MoveMetaAilmentResource(PokeapiCommonViewset):
|
|||
list_serializer_class = MoveMetaAilmentSummarySerializer
|
||||
|
||||
|
||||
class MoveBattleStyleResource(PokeapiCommonViewset):
|
||||
|
||||
queryset = MoveBattleStyle.objects.all()
|
||||
serializer_class = MoveBattleStyleDetailSerializer
|
||||
list_serializer_class = MoveBattleStyleSummarySerializer
|
||||
|
||||
|
||||
class MoveMetaCategoryResource(PokeapiCommonViewset):
|
||||
|
||||
queryset = MoveMetaCategory.objects.all()
|
||||
|
@ -262,6 +290,20 @@ class NatureResource(PokeapiCommonViewset):
|
|||
list_serializer_class = NatureSummarySerializer
|
||||
|
||||
|
||||
class PalParkAreaResource(PokeapiCommonViewset):
|
||||
|
||||
queryset = PalParkArea.objects.all()
|
||||
serializer_class = PalParkAreaDetailSerializer
|
||||
list_serializer_class = PalParkAreaSummarySerializer
|
||||
|
||||
|
||||
class PokeathlonStatResource(PokeapiCommonViewset):
|
||||
|
||||
queryset = PokeathlonStat.objects.all()
|
||||
serializer_class = PokeathlonStatDetailSerializer
|
||||
list_serializer_class = PokeathlonStatSummarySerializer
|
||||
|
||||
|
||||
class PokedexResource(PokeapiCommonViewset):
|
||||
|
||||
queryset = Pokedex.objects.all()
|
||||
|
|
Loading…
Reference in a new issue