mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-10 06:04:18 +00:00
tests covering all endpoints. working on adding some convenience attributes to api resources to help connect them two way style. tests will probably need some small tweaks
This commit is contained in:
commit
1f480cedac
18 changed files with 2091 additions and 359 deletions
|
@ -51,6 +51,7 @@ 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"berry-flavor", BerryFlavorResource)
|
||||
router.register(r"characteristic", CharacteristicResource)
|
||||
router.register(r"contest-type", ContestTypeResource)
|
||||
router.register(r"contest-effect", ContestEffectResource)
|
||||
|
@ -70,7 +71,7 @@ router.register(r"item-fling-effect", ItemFlingEffectResource)
|
|||
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"location-area", LocationAreaResource)
|
||||
# router.register(r"machine", MachineResource)
|
||||
router.register(r"move", MoveResource)
|
||||
router.register(r"move-ailment", MoveMetaAilmentResource)
|
||||
|
|
268
data/v2/build.py
268
data/v2/build.py
|
@ -538,16 +538,16 @@ for index, info in enumerate(data):
|
|||
model.save()
|
||||
|
||||
|
||||
clearTable(ItemFlingEffectDescription)
|
||||
clearTable(ItemFlingEffectEffectText)
|
||||
data = loadData('item_fling_effect_prose.csv')
|
||||
|
||||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
model = ItemFlingEffectDescription (
|
||||
model = ItemFlingEffectEffectText (
|
||||
item_fling_effect = ItemFlingEffect.objects.get(pk = int(info[0])),
|
||||
language = Language.objects.get(pk = int(info[1])),
|
||||
description = info[2]
|
||||
effect = info[2]
|
||||
)
|
||||
model.save()
|
||||
|
||||
|
@ -766,6 +766,102 @@ for index, info in enumerate(data):
|
|||
|
||||
|
||||
|
||||
#############
|
||||
# CONTEST #
|
||||
#############
|
||||
|
||||
clearTable(ContestType)
|
||||
data = loadData('contest_types.csv')
|
||||
|
||||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
model = ContestType (
|
||||
id = int(info[0]),
|
||||
name = info[1]
|
||||
)
|
||||
model.save()
|
||||
|
||||
|
||||
clearTable(ContestTypeName)
|
||||
data = loadData('contest_type_names.csv')
|
||||
|
||||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
model = ContestTypeName (
|
||||
contest_type = ContestType.objects.get(pk = int(info[0])),
|
||||
language = Language.objects.get(pk = int(info[1])),
|
||||
name = info[2],
|
||||
flavor = info[3],
|
||||
color = info[4]
|
||||
)
|
||||
model.save()
|
||||
|
||||
|
||||
clearTable(ContestEffect)
|
||||
data = loadData('contest_effects.csv')
|
||||
|
||||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
model = ContestEffect (
|
||||
id = int(info[0]),
|
||||
appeal = int(info[1]),
|
||||
jam = int(info[2])
|
||||
)
|
||||
model.save()
|
||||
|
||||
|
||||
clearTable(ContestEffectEffectText)
|
||||
data = loadData('contest_effect_prose.csv')
|
||||
|
||||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
model = ContestEffectEffectText (
|
||||
contest_effect = ContestEffect.objects.get(pk = int(info[0])),
|
||||
language = Language.objects.get(pk = int(info[1])),
|
||||
effect = info[3]
|
||||
)
|
||||
model.save()
|
||||
|
||||
model = ContestEffectFlavorText (
|
||||
contest_effect = ContestEffect.objects.get(pk = int(info[0])),
|
||||
language = Language.objects.get(pk = int(info[1])),
|
||||
flavor_text = info[2]
|
||||
)
|
||||
model.save()
|
||||
|
||||
|
||||
clearTable(SuperContestEffect)
|
||||
data = loadData('super_contest_effects.csv')
|
||||
|
||||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
model = SuperContestEffect (
|
||||
id = int(info[0]),
|
||||
appeal = int(info[1])
|
||||
)
|
||||
model.save()
|
||||
|
||||
|
||||
clearTable(SuperContestEffectFlavorText)
|
||||
data = loadData('super_contest_effect_prose.csv')
|
||||
|
||||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
model = SuperContestEffectFlavorText (
|
||||
super_contest_effect = SuperContestEffect.objects.get(pk = int(info[0])),
|
||||
language = Language.objects.get(pk = int(info[1])),
|
||||
flavor_text = info[2]
|
||||
)
|
||||
model.save()
|
||||
|
||||
|
||||
|
||||
###########
|
||||
# MOVES #
|
||||
###########
|
||||
|
@ -934,11 +1030,11 @@ for index, info in enumerate(data):
|
|||
|
||||
move_effect_chance = int(info[11]) if info[11] != '' else None,
|
||||
|
||||
contest_type_id = int(info[12]) if info[12] != '' else None,
|
||||
contest_type = ContestType.objects.get(pk = int(info[12])) if info[12] != '' else None,
|
||||
|
||||
contest_effect_id = int(info[13]) if info[13] != '' else None,
|
||||
contest_effect = ContestEffect.objects.get(pk = int(info[13])) if info[13] != '' else None,
|
||||
|
||||
super_contest_effect_id = int(info[14]) if info[14] != '' else None
|
||||
super_contest_effect = SuperContestEffect.objects.get(pk = int(info[14])) if info[14] != '' else None
|
||||
)
|
||||
model.save()
|
||||
|
||||
|
@ -1164,75 +1260,6 @@ for index, info in enumerate(data):
|
|||
model.save()
|
||||
|
||||
|
||||
|
||||
#############
|
||||
# CONTEST #
|
||||
#############
|
||||
|
||||
clearTable(ContestType)
|
||||
data = loadData('contest_types.csv')
|
||||
|
||||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
model = ContestType (
|
||||
id = int(info[0]),
|
||||
name = info[1]
|
||||
)
|
||||
model.save()
|
||||
|
||||
|
||||
clearTable(ContestTypeName)
|
||||
data = loadData('contest_type_names.csv')
|
||||
|
||||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
model = ContestTypeName (
|
||||
contest_type = ContestType.objects.get(pk = int(info[0])),
|
||||
language = Language.objects.get(pk = int(info[1])),
|
||||
name = info[2],
|
||||
flavor = info[3],
|
||||
color = info[4]
|
||||
)
|
||||
model.save()
|
||||
|
||||
|
||||
clearTable(ContestEffect)
|
||||
data = loadData('contest_effects.csv')
|
||||
|
||||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
model = ContestEffect (
|
||||
id = int(info[0]),
|
||||
appeal = int(info[1]),
|
||||
jam = int(info[2])
|
||||
)
|
||||
model.save()
|
||||
|
||||
|
||||
clearTable(ContestEffectEffectText)
|
||||
data = loadData('contest_effect_prose.csv')
|
||||
|
||||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
model = ContestEffectEffectText (
|
||||
contest_effect = ContestEffect.objects.get(pk = int(info[0])),
|
||||
language = Language.objects.get(pk = int(info[1])),
|
||||
effect = info[3]
|
||||
)
|
||||
model.save()
|
||||
|
||||
model = ContestEffectFlavorText (
|
||||
contest_effect = ContestEffect.objects.get(pk = int(info[0])),
|
||||
language = Language.objects.get(pk = int(info[1])),
|
||||
flavor_text = info[2]
|
||||
)
|
||||
model.save()
|
||||
|
||||
|
||||
clearTable(ContestCombo)
|
||||
data = loadData('contest_combos.csv')
|
||||
|
||||
|
@ -1245,34 +1272,7 @@ for index, info in enumerate(data):
|
|||
)
|
||||
model.save()
|
||||
|
||||
|
||||
clearTable(SuperContestEffect)
|
||||
data = loadData('super_contest_effects.csv')
|
||||
|
||||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
model = SuperContestEffect (
|
||||
id = int(info[0]),
|
||||
appeal = int(info[1])
|
||||
)
|
||||
model.save()
|
||||
|
||||
|
||||
clearTable(SuperContestEffectFlavorText)
|
||||
data = loadData('super_contest_effect_prose.csv')
|
||||
|
||||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
model = SuperContestEffectFlavorText (
|
||||
super_contest_effect = SuperContestEffect.objects.get(pk = int(info[0])),
|
||||
language = Language.objects.get(pk = int(info[1])),
|
||||
flavor_text = info[2]
|
||||
)
|
||||
model.save()
|
||||
|
||||
|
||||
|
||||
clearTable(SuperContestCombo)
|
||||
data = loadData('super_contest_combos.csv')
|
||||
|
||||
|
@ -1343,19 +1343,52 @@ for index, info in enumerate(data):
|
|||
|
||||
|
||||
clearTable(BerryFlavor)
|
||||
data = loadData('berry_flavors.csv')
|
||||
data = loadData('contest_types.csv') #this is not an error
|
||||
|
||||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
# get the english name for this contest type
|
||||
contest_type_name = ContestTypeName.objects.get(contest_type_id=int(info[0]), language_id=9)
|
||||
|
||||
model = BerryFlavor (
|
||||
berry = Berry.objects.get(pk = int(info[0])),
|
||||
contest_type = ContestType.objects.get(pk = int(info[1])),
|
||||
flavor = int(info[2])
|
||||
|
||||
id = int(info[0]),
|
||||
name = contest_type_name.flavor.lower(),
|
||||
contest_type = ContestType.objects.get(pk = int(info[0]))
|
||||
)
|
||||
model.save()
|
||||
|
||||
|
||||
clearTable(BerryFlavorName)
|
||||
data = loadData('contest_type_names.csv') #this is not an error
|
||||
|
||||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
model = BerryFlavorName (
|
||||
|
||||
berry_flavor = BerryFlavor.objects.get(pk = int(info[0])),
|
||||
language = Language.objects.get(pk = int(info[1])),
|
||||
name = info[3]
|
||||
)
|
||||
model.save()
|
||||
|
||||
|
||||
clearTable(BerryFlavorMap)
|
||||
data = loadData('berry_flavors.csv') #this is not an error
|
||||
|
||||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
model = BerryFlavorMap (
|
||||
|
||||
berry = Berry.objects.get(pk = int(info[0])),
|
||||
berry_flavor = BerryFlavor.objects.get(pk = int(info[1])),
|
||||
potency = int(info[2])
|
||||
)
|
||||
model.save()
|
||||
|
||||
|
||||
############
|
||||
# NATURE #
|
||||
|
@ -1367,13 +1400,26 @@ data = loadData('natures.csv')
|
|||
for index, info in enumerate(data):
|
||||
if index > 0:
|
||||
|
||||
decreased_stat = None
|
||||
increased_stat = None
|
||||
hates_flavor = None
|
||||
likes_flavor = None
|
||||
|
||||
if (info[2] != info[3]):
|
||||
decreased_stat = Stat.objects.get(pk = int(info[2]))
|
||||
increased_stat = Stat.objects.get(pk = int(info[3]))
|
||||
|
||||
if (info[4] != info[5]):
|
||||
hates_flavor = BerryFlavor.objects.get(pk = int(info[4]))
|
||||
likes_flavor = BerryFlavor.objects.get(pk = int(info[5]))
|
||||
|
||||
nature = Nature (
|
||||
id = int(info[0]),
|
||||
name = info[1],
|
||||
decreased_stat = Stat.objects.get(pk = int(info[2])),
|
||||
increased_stat = Stat.objects.get(pk = int(info[3])),
|
||||
hates_flavor = BerryFlavor.objects.get(pk = int(info[4])),
|
||||
likes_flavor = BerryFlavor.objects.get(pk = int(info[5])),
|
||||
decreased_stat = decreased_stat,
|
||||
increased_stat = increased_stat,
|
||||
hates_flavor = hates_flavor,
|
||||
likes_flavor = likes_flavor,
|
||||
game_index = info[6]
|
||||
)
|
||||
nature.save()
|
||||
|
|
|
@ -59,7 +59,7 @@ admin.site.register(ItemAttributeMap)
|
|||
admin.site.register(ItemAttributeDescription)
|
||||
admin.site.register(ItemFlavorText)
|
||||
admin.site.register(ItemFlingEffect)
|
||||
admin.site.register(ItemFlingEffectDescription)
|
||||
admin.site.register(ItemFlingEffectEffectText)
|
||||
admin.site.register(ItemGameIndex)
|
||||
admin.site.register(ItemName)
|
||||
admin.site.register(ItemPocketName)
|
||||
|
|
41
pokemon_v2/migrations/0002_auto_20151110_1756.py
Normal file
41
pokemon_v2/migrations/0002_auto_20151110_1756.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pokemon_v2', '0001_squashed_0011_auto_20151108_0352'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='BerryFlavorName',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('name', models.CharField(max_length=100)),
|
||||
('berry_flavor', models.ForeignKey(related_name='berryflavorname', blank=True, to='pokemon_v2.BerryFlavor', null=True)),
|
||||
('language', models.ForeignKey(related_name='berryflavorname_language', blank=True, to='pokemon_v2.Language', null=True)),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='berryflavor',
|
||||
name='berry',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='berryflavor',
|
||||
name='flavor',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='berryflavor',
|
||||
name='name',
|
||||
field=models.CharField(default='name', max_length=100),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
26
pokemon_v2/migrations/0003_berryflavormap.py
Normal file
26
pokemon_v2/migrations/0003_berryflavormap.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', '0002_auto_20151110_1756'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='BerryFlavorMap',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('potency', models.IntegerField()),
|
||||
('berry', models.ForeignKey(related_name='berryflavormap', blank=True, to='pokemon_v2.Berry', null=True)),
|
||||
('berry_flavor', models.ForeignKey(related_name='berryflavormap', blank=True, to='pokemon_v2.BerryFlavor', null=True)),
|
||||
],
|
||||
options={
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
]
|
38
pokemon_v2/migrations/0004_auto_20151111_0531.py
Normal file
38
pokemon_v2/migrations/0004_auto_20151111_0531.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pokemon_v2', '0003_berryflavormap'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='ItemFlingEffectEffectText',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('description', models.CharField(default='', max_length=1000)),
|
||||
('item_fling_effect', models.ForeignKey(related_name='itemflingeffecteffecttext', blank=True, to='pokemon_v2.ItemFlingEffect', null=True)),
|
||||
('language', models.ForeignKey(related_name='itemflingeffecteffecttext_language', blank=True, to='pokemon_v2.Language', null=True)),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='itemflingeffectdescription',
|
||||
name='item_fling_effect',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='itemflingeffectdescription',
|
||||
name='language',
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='ItemFlingEffectDescription',
|
||||
),
|
||||
]
|
24
pokemon_v2/migrations/0005_auto_20151111_0541.py
Normal file
24
pokemon_v2/migrations/0005_auto_20151111_0541.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pokemon_v2', '0004_auto_20151111_0531'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='itemflingeffecteffecttext',
|
||||
name='description',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='itemflingeffecteffecttext',
|
||||
name='effect',
|
||||
field=models.CharField(default='string', max_length=4000),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
20
pokemon_v2/migrations/0006_auto_20151111_2216.py
Normal file
20
pokemon_v2/migrations/0006_auto_20151111_2216.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pokemon_v2', '0005_auto_20151111_0541'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='palpark',
|
||||
name='pal_park_area',
|
||||
field=models.ForeignKey(related_name='palpark', blank=True, to='pokemon_v2.PalParkArea', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
20
pokemon_v2/migrations/0007_auto_20151113_1414.py
Normal file
20
pokemon_v2/migrations/0007_auto_20151113_1414.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pokemon_v2', '0006_auto_20151111_2216'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='berry',
|
||||
name='berry_firmness',
|
||||
field=models.ForeignKey(related_name='berry', blank=True, to='pokemon_v2.BerryFirmness', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
20
pokemon_v2/migrations/0008_auto_20151114_0241.py
Normal file
20
pokemon_v2/migrations/0008_auto_20151114_0241.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pokemon_v2', '0007_auto_20151113_1414'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='berryflavor',
|
||||
name='contest_type',
|
||||
field=models.OneToOneField(related_name='berryflavor', null=True, blank=True, to='pokemon_v2.ContestType'),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
44
pokemon_v2/migrations/0009_auto_20151114_0433.py
Normal file
44
pokemon_v2/migrations/0009_auto_20151114_0433.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', '0008_auto_20151114_0241'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='move',
|
||||
name='contest_effect_id',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='move',
|
||||
name='contest_type_id',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='move',
|
||||
name='super_contest_effect_id',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='move',
|
||||
name='contest_effect',
|
||||
field=models.ForeignKey(related_name='move', blank=True, to='pokemon_v2.ContestEffect', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='move',
|
||||
name='contest_type',
|
||||
field=models.ForeignKey(related_name='move', blank=True, to='pokemon_v2.ContestType', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='move',
|
||||
name='super_contest_effect',
|
||||
field=models.ForeignKey(related_name='move', blank=True, to='pokemon_v2.SuperContestEffect', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
20
pokemon_v2/migrations/0010_auto_20151116_0219.py
Normal file
20
pokemon_v2/migrations/0010_auto_20151116_0219.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pokemon_v2', '0009_auto_20151114_0433'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='pokemonspecies',
|
||||
name='pokemon_habitat',
|
||||
field=models.ForeignKey(related_name='pokemonspecies', blank=True, to='pokemon_v2.PokemonHabitat', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
20
pokemon_v2/migrations/0011_auto_20151116_0230.py
Normal file
20
pokemon_v2/migrations/0011_auto_20151116_0230.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pokemon_v2', '0010_auto_20151116_0219'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='pokemonspecies',
|
||||
name='pokemon_shape',
|
||||
field=models.ForeignKey(related_name='pokemonspecies', blank=True, to='pokemon_v2.PokemonShape', null=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
20
pokemon_v2/migrations/0012_auto_20151116_0317.py
Normal file
20
pokemon_v2/migrations/0012_auto_20151116_0317.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pokemon_v2', '0011_auto_20151116_0230'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='generation',
|
||||
name='region',
|
||||
field=models.OneToOneField(related_name='generation', null=True, blank=True, to='pokemon_v2.Region'),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
|
@ -30,6 +30,22 @@ class HasContestType(models.Model):
|
|||
abstract = True
|
||||
|
||||
|
||||
class HasContestEffect(models.Model):
|
||||
|
||||
contest_effect = models.ForeignKey('ContestEffect', blank=True, null=True, related_name="%(class)s")
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
||||
class HasSuperContestEffect(models.Model):
|
||||
|
||||
super_contest_effect = models.ForeignKey('SuperContestEffect', blank = True, null = True, related_name="%(class)s")
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
||||
class HasDescription(models.Model):
|
||||
|
||||
description = models.CharField(max_length=1000, default='')
|
||||
|
@ -321,7 +337,7 @@ class HasMoveLearnMethod(models.Model):
|
|||
|
||||
class HasPokemonShape(models.Model):
|
||||
|
||||
pokemon_shape = models.ForeignKey('PokemonShape', blank=True, null=True, )
|
||||
pokemon_shape = models.ForeignKey('PokemonShape', blank=True, null=True, related_name="%(class)s")
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
@ -449,8 +465,9 @@ class LanguageName(IsName):
|
|||
# GENERATION MODELS #
|
||||
#######################
|
||||
|
||||
class Generation(HasName, HasRegion):
|
||||
pass
|
||||
class Generation(HasName):
|
||||
|
||||
region = models.OneToOneField('Region', blank=True, null=True, related_name="%(class)s")
|
||||
|
||||
|
||||
class GenerationName(IsName, HasGeneration):
|
||||
|
@ -595,7 +612,7 @@ class ItemFlingEffect(HasName):
|
|||
pass
|
||||
|
||||
|
||||
class ItemFlingEffectDescription(IsDescription, HasFlingEffect):
|
||||
class ItemFlingEffectEffectText(HasLanguage, HasEffect, HasFlingEffect):
|
||||
pass
|
||||
|
||||
|
||||
|
@ -661,14 +678,12 @@ class ContestEffect(models.Model):
|
|||
jam = models.IntegerField()
|
||||
|
||||
|
||||
class ContestEffectEffectText(HasLanguage, HasEffect):
|
||||
|
||||
contest_effect = models.ForeignKey(ContestEffect, blank=True, null=True, related_name="%(class)s")
|
||||
class ContestEffectEffectText(HasLanguage, HasEffect, HasContestEffect):
|
||||
pass
|
||||
|
||||
|
||||
class ContestEffectFlavorText(HasLanguage, HasFlavorText):
|
||||
|
||||
contest_effect = models.ForeignKey(ContestEffect, blank=True, null=True, related_name="%(class)s")
|
||||
class ContestEffectFlavorText(HasLanguage, HasFlavorText, HasContestEffect):
|
||||
pass
|
||||
|
||||
|
||||
class ContestCombo(models.Model):
|
||||
|
@ -694,7 +709,7 @@ class BerryFirmnessName(IsName):
|
|||
|
||||
class Berry(HasName, HasItem, HasNature):
|
||||
|
||||
berry_firmness = models.ForeignKey(BerryFirmness, blank=True, null=True)
|
||||
berry_firmness = models.ForeignKey(BerryFirmness, blank=True, null=True, related_name="%(class)s")
|
||||
|
||||
natural_gift_power = models.IntegerField()
|
||||
|
||||
|
@ -709,11 +724,30 @@ class Berry(HasName, HasItem, HasNature):
|
|||
smoothness = models.IntegerField()
|
||||
|
||||
|
||||
class BerryFlavor(HasContestType):
|
||||
"""
|
||||
Berry Flavors are a bit of a hack because their relationship
|
||||
in terms of flavors to contest types is really awkward the
|
||||
way it was handled in the veekun data set. Berry Flavor here
|
||||
does not match the csv table. Berry Flavor Map
|
||||
is a table fabricated just to suit this project.
|
||||
"""
|
||||
class BerryFlavor(HasName):
|
||||
|
||||
contest_type = models.OneToOneField('ContestType', blank=True, null=True, related_name="%(class)s")
|
||||
|
||||
|
||||
class BerryFlavorName(IsName):
|
||||
|
||||
berry_flavor = models.ForeignKey(BerryFlavor, blank=True, null=True, related_name="%(class)s")
|
||||
|
||||
|
||||
class BerryFlavorMap(models.Model):
|
||||
|
||||
berry = models.ForeignKey(Berry, blank=True, null=True, related_name="%(class)s")
|
||||
|
||||
flavor = models.IntegerField()
|
||||
berry_flavor = models.ForeignKey(BerryFlavor, blank=True, null=True, related_name="%(class)s")
|
||||
|
||||
potency = models.IntegerField()
|
||||
|
||||
|
||||
|
||||
|
@ -855,7 +889,7 @@ class EncounterConditionValueMap(models.Model):
|
|||
# MOVE MODELS #
|
||||
#################
|
||||
|
||||
class Move(HasName, HasGeneration, HasType, HasMoveDamageClass, HasMoveEffect, HasMoveTarget):
|
||||
class Move(HasName, HasGeneration, HasType, HasMoveDamageClass, HasMoveEffect, HasMoveTarget, HasContestType, HasContestEffect, HasSuperContestEffect):
|
||||
|
||||
power = models.IntegerField(blank = True, null = True)
|
||||
|
||||
|
@ -867,11 +901,6 @@ class Move(HasName, HasGeneration, HasType, HasMoveDamageClass, HasMoveEffect, H
|
|||
|
||||
move_effect_chance = models.IntegerField(blank = True, null = True)
|
||||
|
||||
contest_type_id = models.IntegerField(blank = True, null = True)
|
||||
|
||||
contest_effect_id = models.IntegerField(blank = True, null = True)
|
||||
|
||||
super_contest_effect_id = models.IntegerField(blank = True, null = True)
|
||||
|
||||
|
||||
class MoveName(HasMove, IsName):
|
||||
|
@ -1097,7 +1126,7 @@ class PalParkAreaName(IsName):
|
|||
|
||||
class PalPark(HasPokemonSpecies):
|
||||
|
||||
pal_park_area = models.ForeignKey(PalParkArea, blank = True, null = True)
|
||||
pal_park_area = models.ForeignKey(PalParkArea, blank = True, null = True, related_name="%(class)s")
|
||||
|
||||
base_score = models.IntegerField(blank = True, null = True)
|
||||
|
||||
|
@ -1114,9 +1143,8 @@ class SuperContestEffect(models.Model):
|
|||
appeal = models.IntegerField()
|
||||
|
||||
|
||||
class SuperContestEffectFlavorText(IsFlavorText):
|
||||
|
||||
super_contest_effect = models.ForeignKey(SuperContestEffect, blank = True, null = True, related_name="%(class)s")
|
||||
class SuperContestEffectFlavorText(IsFlavorText, HasSuperContestEffect):
|
||||
pass
|
||||
|
||||
|
||||
class SuperContestCombo(models.Model):
|
||||
|
@ -1178,7 +1206,7 @@ class PokemonSpecies(HasName, HasGeneration, HasPokemonColor,
|
|||
|
||||
evolution_chain = models.ForeignKey(EvolutionChain, blank=True, null=True)
|
||||
|
||||
pokemon_habitat = models.ForeignKey('PokemonHabitat', blank=True, null=True)
|
||||
pokemon_habitat = models.ForeignKey('PokemonHabitat', blank=True, null=True, related_name="%(class)s")
|
||||
|
||||
gender_rate = models.IntegerField()
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
1216
pokemon_v2/tests.py
1216
pokemon_v2/tests.py
File diff suppressed because it is too large
Load diff
|
@ -86,6 +86,12 @@ class BerryFirmnessResource(PokeapiCommonViewset):
|
|||
serializer_class = BerryFirmnessDetailSerializer
|
||||
list_serializer_class = BerryFirmnessSummarySerializer
|
||||
|
||||
class BerryFlavorResource(PokeapiCommonViewset):
|
||||
|
||||
queryset = BerryFlavor.objects.all()
|
||||
serializer_class = BerryFlavorDetailSerializer
|
||||
list_serializer_class = BerryFlavorSummarySerializer
|
||||
|
||||
|
||||
class CharacteristicResource(PokeapiCommonViewset):
|
||||
|
||||
|
@ -220,7 +226,7 @@ class LocationResource(PokeapiCommonViewset):
|
|||
list_serializer_class = LocationSummarySerializer
|
||||
|
||||
|
||||
class LocationAreaResource(PokeapiCommonViewset):
|
||||
class LocationAreaResource(ListOrDetailSerialRelation, viewsets.ReadOnlyModelViewSet):
|
||||
|
||||
queryset = LocationArea.objects.all()
|
||||
serializer_class = LocationAreaDetailSerializer
|
||||
|
|
Loading…
Reference in a new issue