mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-25 12:50:18 +00:00
More Models
Whole bunch of modelin’ goin’ on around here
This commit is contained in:
parent
d9720665b8
commit
9a255298fc
12 changed files with 719 additions and 158 deletions
264
data/v2/build.py
264
data/v2/build.py
|
@ -3,38 +3,268 @@ import os
|
||||||
|
|
||||||
from pokemon_v2.models import *
|
from pokemon_v2.models import *
|
||||||
|
|
||||||
|
|
||||||
|
data_location = 'data/v2/csv/'
|
||||||
|
|
||||||
|
|
||||||
|
def loadData(fileName):
|
||||||
|
return csv.reader(open(data_location + fileName, 'rb'), delimiter=',')
|
||||||
|
|
||||||
|
def clearTable(model):
|
||||||
|
model.objects.all().delete()
|
||||||
|
|
||||||
|
|
||||||
|
##############
|
||||||
|
# LANGUAGE #
|
||||||
|
##############
|
||||||
|
|
||||||
|
clearTable(Language)
|
||||||
|
print str(Language)
|
||||||
|
data = loadData('languages.csv')
|
||||||
|
|
||||||
|
for index, info in enumerate(data):
|
||||||
|
if index > 0:
|
||||||
|
|
||||||
|
language = Language (
|
||||||
|
id = int(info[0]),
|
||||||
|
iso639 = info[1],
|
||||||
|
iso3166 = info[2],
|
||||||
|
name = info[3],
|
||||||
|
official = bool(info[4]),
|
||||||
|
order = info[5],
|
||||||
|
)
|
||||||
|
|
||||||
|
language.save()
|
||||||
|
|
||||||
|
|
||||||
|
clearTable(LanguageName)
|
||||||
|
data = loadData('language_names.csv')
|
||||||
|
|
||||||
|
for index, info in enumerate(data):
|
||||||
|
if index > 0:
|
||||||
|
|
||||||
|
languageName = LanguageName (
|
||||||
|
language = Language.objects.filter(id = int(info[0]))[0],
|
||||||
|
local_language_id = int(info[1]),
|
||||||
|
name = info[2]
|
||||||
|
)
|
||||||
|
|
||||||
|
languageName.save()
|
||||||
|
|
||||||
|
|
||||||
|
################
|
||||||
|
# GENERATION #
|
||||||
|
################
|
||||||
|
|
||||||
|
clearTable(Generation)
|
||||||
|
data = loadData('generations.csv')
|
||||||
|
|
||||||
|
for index, info in enumerate(data):
|
||||||
|
if index > 0:
|
||||||
|
|
||||||
|
generation = Generation (
|
||||||
|
id = int(info[0]),
|
||||||
|
main_region_id = info[1],
|
||||||
|
name = info[2]
|
||||||
|
)
|
||||||
|
generation.save()
|
||||||
|
|
||||||
|
|
||||||
|
clearTable(GenerationName)
|
||||||
|
data = loadData('generation_names.csv')
|
||||||
|
|
||||||
|
for index, info in enumerate(data):
|
||||||
|
if index > 0:
|
||||||
|
|
||||||
|
generationName = GenerationName (
|
||||||
|
generation = Generation.objects.filter(id = int(info[0]))[0],
|
||||||
|
language = Language.objects.filter(id = int(info[1]))[0],
|
||||||
|
name = info[2]
|
||||||
|
)
|
||||||
|
generationName.save()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#############
|
||||||
|
# VERSION #
|
||||||
|
#############
|
||||||
|
|
||||||
|
clearTable(VersionGroup)
|
||||||
|
data = loadData('version_groups.csv')
|
||||||
|
|
||||||
|
for index, info in enumerate(data):
|
||||||
|
if index > 0:
|
||||||
|
|
||||||
|
versionGroup = VersionGroup (
|
||||||
|
id = int(info[0]),
|
||||||
|
name = info[1],
|
||||||
|
generation = Generation.objects.filter(id = int(info[2]))[0],
|
||||||
|
order = int(info[3])
|
||||||
|
)
|
||||||
|
versionGroup.save()
|
||||||
|
|
||||||
|
|
||||||
|
clearTable(VersionGroupRegion)
|
||||||
|
data = loadData('version_group_regions.csv')
|
||||||
|
|
||||||
|
for index, info in enumerate(data):
|
||||||
|
if index > 0:
|
||||||
|
|
||||||
|
versionGroupRegion = VersionGroupRegion (
|
||||||
|
version_group = VersionGroup.objects.filter(id = int(info[0]))[0],
|
||||||
|
region_id = int(info[1])
|
||||||
|
)
|
||||||
|
versionGroupRegion.save()
|
||||||
|
|
||||||
|
|
||||||
|
clearTable(Version)
|
||||||
|
data = loadData('versions.csv')
|
||||||
|
|
||||||
|
for index, info in enumerate(data):
|
||||||
|
if index > 0:
|
||||||
|
|
||||||
|
version = Version (
|
||||||
|
id = int(info[0]),
|
||||||
|
version_group = VersionGroup.objects.filter(id = int(info[1]))[0],
|
||||||
|
name = info[2]
|
||||||
|
)
|
||||||
|
version.save()
|
||||||
|
|
||||||
|
|
||||||
|
clearTable(VersionName)
|
||||||
|
data = loadData('version_names.csv')
|
||||||
|
|
||||||
|
for index, info in enumerate(data):
|
||||||
|
if index > 0:
|
||||||
|
|
||||||
|
versionName = VersionName (
|
||||||
|
version = Version.objects.filter(id = int(info[0]))[0],
|
||||||
|
language = Language.objects.filter(id = int(info[1]))[0],
|
||||||
|
name = info[2]
|
||||||
|
)
|
||||||
|
versionName.save()
|
||||||
|
|
||||||
|
|
||||||
###############
|
###############
|
||||||
# ABILITIES #
|
# ABILITIES #
|
||||||
###############
|
###############
|
||||||
|
|
||||||
# Names #
|
clearTable(Ability)
|
||||||
|
data = loadData('abilities.csv')
|
||||||
file = open('data/v2/csv/ability_names.csv', 'rb')
|
|
||||||
data = csv.reader(file, delimiter=',')
|
|
||||||
|
|
||||||
for index, info in enumerate(data):
|
for index, info in enumerate(data):
|
||||||
if index > 0:
|
if index > 0:
|
||||||
|
|
||||||
abilityName = AbilityName(
|
ability = Ability (
|
||||||
ability_id=int(info[0]),
|
id = int(info[0]),
|
||||||
local_language_id=int(info[1]),
|
name = info[1],
|
||||||
name=info[2]
|
generation = Generation.objects.filter(id = int(info[2]))[0],
|
||||||
|
is_main_series = bool(info[3])
|
||||||
|
)
|
||||||
|
ability.save()
|
||||||
|
|
||||||
|
|
||||||
|
clearTable(AbilityName)
|
||||||
|
data = loadData('ability_names.csv')
|
||||||
|
|
||||||
|
for index, info in enumerate(data):
|
||||||
|
if index > 0:
|
||||||
|
|
||||||
|
abilityName = AbilityName (
|
||||||
|
ability = Ability.objects.filter(id = int(info[0]))[0],
|
||||||
|
language = Language.objects.filter(id = int(info[1]))[0],
|
||||||
|
name = info[2]
|
||||||
)
|
)
|
||||||
abilityName.save()
|
abilityName.save()
|
||||||
|
|
||||||
|
|
||||||
# Descriptions #
|
clearTable(AbilityDescription)
|
||||||
|
data = loadData('ability_prose.csv')
|
||||||
file = open('data/v2/csv/ability_prose.csv', 'rb')
|
|
||||||
data = csv.reader(file, delimiter=',')
|
|
||||||
|
|
||||||
for index, info in enumerate(data):
|
for index, info in enumerate(data):
|
||||||
if index > 0:
|
if index > 0:
|
||||||
|
|
||||||
abilityDesc = AbilityDescription(
|
abilityDesc = AbilityDescription (
|
||||||
ability_id=int(info[0]),
|
ability = Ability.objects.filter(id = int(info[0]))[0],
|
||||||
local_language_id=int(info[1]),
|
language = Language.objects.filter(id = int(info[1]))[0],
|
||||||
short_effect=info[2],
|
short_effect = info[2],
|
||||||
effect=info[3]
|
effect = info[3]
|
||||||
)
|
)
|
||||||
abilityDesc.save()
|
abilityDesc.save()
|
||||||
|
|
||||||
|
|
||||||
|
clearTable(AbilityFlavorText)
|
||||||
|
data = loadData('ability_flavor_text.csv')
|
||||||
|
|
||||||
|
for index, info in enumerate(data):
|
||||||
|
if index > 0:
|
||||||
|
|
||||||
|
abilityFlavorText = AbilityFlavorText (
|
||||||
|
ability = Ability.objects.filter(id = int(info[0]))[0],
|
||||||
|
version_group = VersionGroup.objects.filter(id = int(info[1]))[0],
|
||||||
|
language = Language.objects.filter(id = int(info[2]))[0],
|
||||||
|
flavor_text = info[2]
|
||||||
|
)
|
||||||
|
abilityFlavorText.save()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###########
|
||||||
|
# TYPES #
|
||||||
|
###########
|
||||||
|
|
||||||
|
clearTable(Type)
|
||||||
|
data = loadData('types.csv')
|
||||||
|
|
||||||
|
for index, info in enumerate(data):
|
||||||
|
if index > 0:
|
||||||
|
|
||||||
|
type = Type (
|
||||||
|
id = int(info[0]),
|
||||||
|
name = info[1],
|
||||||
|
generation = Generation.objects.filter(id = int(info[2]))[0],
|
||||||
|
damage_class_id = int(info[3]) if info[3] else 0
|
||||||
|
)
|
||||||
|
type.save()
|
||||||
|
|
||||||
|
|
||||||
|
clearTable(TypeName)
|
||||||
|
data = loadData('type_names.csv')
|
||||||
|
|
||||||
|
for index, info in enumerate(data):
|
||||||
|
if index > 0:
|
||||||
|
|
||||||
|
typeName = TypeName (
|
||||||
|
type = Type.objects.filter(id = int(info[0]))[0],
|
||||||
|
language = Language.objects.filter(id = int(info[1]))[0],
|
||||||
|
name = info[2]
|
||||||
|
)
|
||||||
|
typeName.save()
|
||||||
|
|
||||||
|
|
||||||
|
clearTable(TypeGameIndex)
|
||||||
|
data = loadData('type_game_indices.csv')
|
||||||
|
|
||||||
|
for index, info in enumerate(data):
|
||||||
|
if index > 0:
|
||||||
|
|
||||||
|
typeGameIndex = TypeGameIndex (
|
||||||
|
type = Type.objects.filter(id = int(info[0]))[0],
|
||||||
|
generation = Generation.objects.filter(id = int(info[1]))[0],
|
||||||
|
game_index = int(info[2])
|
||||||
|
)
|
||||||
|
typeGameIndex.save()
|
||||||
|
|
||||||
|
|
||||||
|
clearTable(TypeEfficacy)
|
||||||
|
data = loadData('type_efficacy.csv')
|
||||||
|
|
||||||
|
for index, info in enumerate(data):
|
||||||
|
if index > 0:
|
||||||
|
|
||||||
|
typeEfficacy = TypeEfficacy (
|
||||||
|
damage_type_id = int(info[0]),
|
||||||
|
target_type_id = int(info[1]),
|
||||||
|
damage_factor = int(info[2])
|
||||||
|
)
|
||||||
|
typeEfficacy.save()
|
||||||
|
|
|
@ -3,6 +3,18 @@ from django.contrib import admin
|
||||||
|
|
||||||
from .models import *
|
from .models import *
|
||||||
|
|
||||||
|
admin.site.register(Language)
|
||||||
|
admin.site.register(LanguageName)
|
||||||
|
|
||||||
|
admin.site.register(Generation)
|
||||||
|
admin.site.register(GenerationName)
|
||||||
|
|
||||||
|
admin.site.register(Version)
|
||||||
|
admin.site.register(VersionName)
|
||||||
|
admin.site.register(VersionGroup)
|
||||||
|
admin.site.register(VersionGroupRegion)
|
||||||
|
admin.site.register(VersionGroupPokemonMoveMethod)
|
||||||
|
|
||||||
admin.site.register(Ability)
|
admin.site.register(Ability)
|
||||||
admin.site.register(AbilityName)
|
admin.site.register(AbilityName)
|
||||||
admin.site.register(AbilityDescription)
|
admin.site.register(AbilityDescription)
|
||||||
|
|
|
@ -1,81 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import models, migrations
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='Ability',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
|
||||||
('generation', models.IntegerField()),
|
|
||||||
('is_main_series', models.IntegerField()),
|
|
||||||
('name', models.CharField(max_length=30)),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
},
|
|
||||||
bases=(models.Model,),
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='AbilityDescription',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
|
||||||
('ability_id', models.IntegerField()),
|
|
||||||
('local_language_id', models.IntegerField()),
|
|
||||||
('short_effect', models.CharField(max_length=200)),
|
|
||||||
('effect', models.CharField(max_length=2000)),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
},
|
|
||||||
bases=(models.Model,),
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='AbilityFlavorText',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
|
||||||
('ability_id', models.IntegerField()),
|
|
||||||
('version_group_id', models.IntegerField()),
|
|
||||||
('language_id', models.IntegerField()),
|
|
||||||
('flavor_text', models.CharField(max_length=100)),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
},
|
|
||||||
bases=(models.Model,),
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='AbilityName',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
|
||||||
('ability_id', models.IntegerField()),
|
|
||||||
('local_language_id', models.IntegerField()),
|
|
||||||
('name', models.CharField(max_length=30)),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
},
|
|
||||||
bases=(models.Model,),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='ability',
|
|
||||||
name='description',
|
|
||||||
field=models.OneToOneField(null=True, blank=True, to='pokemon_v2.AbilityDescription'),
|
|
||||||
preserve_default=True,
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='ability',
|
|
||||||
name='flavor_text',
|
|
||||||
field=models.ForeignKey(blank=True, to='pokemon_v2.AbilityFlavorText', null=True),
|
|
||||||
preserve_default=True,
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='ability',
|
|
||||||
name='names',
|
|
||||||
field=models.ForeignKey(blank=True, to='pokemon_v2.AbilityName', null=True),
|
|
||||||
preserve_default=True,
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -12,9 +12,9 @@ class Migration(migrations.Migration):
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='abilitydescription',
|
model_name='languagename',
|
||||||
name='effect',
|
name='language_id',
|
||||||
field=models.CharField(max_length=2001),
|
field=models.ForeignKey(related_name='language_id', blank=True, to='pokemon_v2.Language', null=True),
|
||||||
preserve_default=True,
|
preserve_default=True,
|
||||||
),
|
),
|
||||||
]
|
]
|
|
@ -1,26 +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_20150403_0536'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='abilitydescription',
|
|
||||||
name='effect',
|
|
||||||
field=models.CharField(max_length=2000),
|
|
||||||
preserve_default=True,
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='abilitydescription',
|
|
||||||
name='short_effect',
|
|
||||||
field=models.CharField(max_length=300),
|
|
||||||
preserve_default=True,
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -7,14 +7,14 @@ from django.db import models, migrations
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('pokemon_v2', '0002_auto_20150403_0522'),
|
('pokemon_v2', '0002_auto_20150405_2102'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name='abilitydescription',
|
model_name='languagename',
|
||||||
name='effect',
|
name='language_id',
|
||||||
field=models.CharField(max_length=2001),
|
field=models.ForeignKey(related_name='language', blank=True, to='pokemon_v2.Language', null=True),
|
||||||
preserve_default=True,
|
preserve_default=True,
|
||||||
),
|
),
|
||||||
]
|
]
|
24
pokemon_v2/migrations/0004_auto_20150405_2112.py
Normal file
24
pokemon_v2/migrations/0004_auto_20150405_2112.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', '0003_auto_20150405_2109'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='languagename',
|
||||||
|
name='language_id',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='languagename',
|
||||||
|
name='language',
|
||||||
|
field=models.ForeignKey(blank=True, to='pokemon_v2.Language', null=True),
|
||||||
|
preserve_default=True,
|
||||||
|
),
|
||||||
|
]
|
38
pokemon_v2/migrations/0005_generation_generationname.py
Normal file
38
pokemon_v2/migrations/0005_generation_generationname.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', '0004_auto_20150405_2112'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Generation',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('main_region_id', models.IntegerField()),
|
||||||
|
('name', models.CharField(max_length=30)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
},
|
||||||
|
bases=(models.Model,),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='GenerationName',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('local_language_id', models.IntegerField()),
|
||||||
|
('name', models.CharField(max_length=30)),
|
||||||
|
('generation', models.ForeignKey(blank=True, to='pokemon_v2.Generation', null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=(models.Model,),
|
||||||
|
),
|
||||||
|
]
|
162
pokemon_v2/migrations/0006_auto_20150406_0336.py
Normal file
162
pokemon_v2/migrations/0006_auto_20150406_0336.py
Normal file
|
@ -0,0 +1,162 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('pokemon_v2', '0005_generation_generationname'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Ability',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('name', models.CharField(max_length=30)),
|
||||||
|
('is_main_series', models.BooleanField(default=False)),
|
||||||
|
('generation', models.ForeignKey(blank=True, to='pokemon_v2.Generation', null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=(models.Model,),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='AbilityDescription',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('short_effect', models.CharField(max_length=300)),
|
||||||
|
('effect', models.CharField(max_length=2000)),
|
||||||
|
('ability', models.ForeignKey(blank=True, to='pokemon_v2.Ability', null=True)),
|
||||||
|
('language', models.ForeignKey(blank=True, to='pokemon_v2.Language', null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=(models.Model,),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='AbilityFlavorText',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('flavor_text', models.CharField(max_length=100)),
|
||||||
|
('ability', models.ForeignKey(blank=True, to='pokemon_v2.Ability', null=True)),
|
||||||
|
('language', models.ForeignKey(blank=True, to='pokemon_v2.Language', null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=(models.Model,),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='AbilityName',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('name', models.CharField(max_length=30)),
|
||||||
|
('ability', models.ForeignKey(blank=True, to='pokemon_v2.Ability', null=True)),
|
||||||
|
('language', models.ForeignKey(blank=True, to='pokemon_v2.Language', null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=(models.Model,),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Version',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('name', models.CharField(max_length=30)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=(models.Model,),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='VersionGroup',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('name', models.CharField(max_length=30)),
|
||||||
|
('order', models.IntegerField()),
|
||||||
|
('generation', models.ForeignKey(blank=True, to='pokemon_v2.Generation', null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=(models.Model,),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='VersionGroupPokemonMoveMethod',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('pokemon_move_method_id', models.IntegerField()),
|
||||||
|
('version_group', models.ForeignKey(blank=True, to='pokemon_v2.VersionGroup', null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=(models.Model,),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='VersionGroupRegion',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('region_id', models.IntegerField()),
|
||||||
|
('version_group', models.ForeignKey(blank=True, to='pokemon_v2.VersionGroup', null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=(models.Model,),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='VersionName',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('name', models.CharField(max_length=30)),
|
||||||
|
('language', models.ForeignKey(blank=True, to='pokemon_v2.Language', null=True)),
|
||||||
|
('version', models.ForeignKey(blank=True, to='pokemon_v2.Version', null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=(models.Model,),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='version',
|
||||||
|
name='version_group',
|
||||||
|
field=models.ForeignKey(blank=True, to='pokemon_v2.VersionGroup', null=True),
|
||||||
|
preserve_default=True,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='abilityflavortext',
|
||||||
|
name='version_group',
|
||||||
|
field=models.ForeignKey(blank=True, to='pokemon_v2.VersionGroup', null=True),
|
||||||
|
preserve_default=True,
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='generationname',
|
||||||
|
name='local_language_id',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='generationname',
|
||||||
|
name='language',
|
||||||
|
field=models.ForeignKey(blank=True, to='pokemon_v2.Language', null=True),
|
||||||
|
preserve_default=True,
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='language',
|
||||||
|
name='name',
|
||||||
|
field=models.CharField(max_length=30),
|
||||||
|
preserve_default=True,
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='language',
|
||||||
|
name='official',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
preserve_default=True,
|
||||||
|
),
|
||||||
|
]
|
53
pokemon_v2/migrations/0007_type_typegameindex_typename.py
Normal file
53
pokemon_v2/migrations/0007_type_typegameindex_typename.py
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import models, migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('pokemon_v2', '0006_auto_20150406_0336'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Type',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('name', models.CharField(max_length=30)),
|
||||||
|
('damage_class_id', models.IntegerField()),
|
||||||
|
('generation', models.ForeignKey(blank=True, to='pokemon_v2.Generation', null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=(models.Model,),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='TypeGameIndex',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('game_index', models.IntegerField()),
|
||||||
|
('generation', models.ForeignKey(blank=True, to='pokemon_v2.Generation', null=True)),
|
||||||
|
('type', models.ForeignKey(blank=True, to='pokemon_v2.Type', null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=(models.Model,),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='TypeName',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('name', models.CharField(max_length=30)),
|
||||||
|
('language', models.ForeignKey(blank=True, to='pokemon_v2.Language', null=True)),
|
||||||
|
('type', models.ForeignKey(blank=True, to='pokemon_v2.Type', null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'abstract': False,
|
||||||
|
},
|
||||||
|
bases=(models.Model,),
|
||||||
|
),
|
||||||
|
]
|
26
pokemon_v2/migrations/0008_typeefficacy.py
Normal file
26
pokemon_v2/migrations/0008_typeefficacy.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', '0007_type_typegameindex_typename'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='TypeEfficacy',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('damage_type_id', models.IntegerField()),
|
||||||
|
('target_type_id', models.IntegerField()),
|
||||||
|
('damage_factor', models.IntegerField()),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
},
|
||||||
|
bases=(models.Model,),
|
||||||
|
),
|
||||||
|
]
|
|
@ -2,51 +2,174 @@ from __future__ import unicode_literals
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
class AbilityDescription(models.Model):
|
#####################
|
||||||
|
# ABSTRACT MODELS #
|
||||||
|
#####################
|
||||||
|
|
||||||
ability_id = models.IntegerField()
|
class HasLanguage(models.Model):
|
||||||
|
|
||||||
|
language = models.ForeignKey('Language', blank = True, null = True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
class HasName(models.Model):
|
||||||
|
|
||||||
|
name = models.CharField(max_length=30)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
class IsName(HasLanguage, HasName):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
class HasOrder(models.Model):
|
||||||
|
|
||||||
|
order = models.IntegerField()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
class HasAbility(models.Model):
|
||||||
|
|
||||||
|
ability = models.ForeignKey('Ability', blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
class HasGeneration(models.Model):
|
||||||
|
|
||||||
|
generation = models.ForeignKey('Generation', blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
class HasVersionGroup(models.Model):
|
||||||
|
|
||||||
|
version_group = models.ForeignKey('VersionGroup', blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
class HasType(models.Model):
|
||||||
|
|
||||||
|
type = models.ForeignKey('Type', blank=True, null=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
####################
|
||||||
|
# VERSION MODELS #
|
||||||
|
####################
|
||||||
|
|
||||||
|
class Version(HasName, HasVersionGroup):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class VersionName(IsName):
|
||||||
|
|
||||||
|
version = models.ForeignKey('Version', blank=True, null=True)
|
||||||
|
|
||||||
|
|
||||||
|
class VersionGroup(HasName, HasGeneration, HasOrder):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class VersionGroupRegion(HasVersionGroup):
|
||||||
|
|
||||||
|
region_id = models.IntegerField()
|
||||||
|
|
||||||
|
|
||||||
|
class VersionGroupPokemonMoveMethod(HasVersionGroup):
|
||||||
|
|
||||||
|
pokemon_move_method_id = models.IntegerField()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#####################
|
||||||
|
# LANGUAGE MODELS #
|
||||||
|
#####################
|
||||||
|
|
||||||
|
class Language(HasName, HasOrder):
|
||||||
|
|
||||||
|
iso639 = models.CharField(max_length=2)
|
||||||
|
|
||||||
|
iso3166 = models.CharField(max_length=2)
|
||||||
|
|
||||||
|
official = models.BooleanField(default = False)
|
||||||
|
|
||||||
|
|
||||||
|
class LanguageName(IsName):
|
||||||
|
|
||||||
local_language_id = models.IntegerField()
|
local_language_id = models.IntegerField()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#######################
|
||||||
|
# GENERATION MODELS #
|
||||||
|
#######################
|
||||||
|
|
||||||
|
class Generation(HasName):
|
||||||
|
|
||||||
|
main_region_id = models.IntegerField()
|
||||||
|
|
||||||
|
|
||||||
|
class GenerationName(IsName, HasGeneration):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
####################
|
||||||
|
# ABILITY MODELS #
|
||||||
|
####################
|
||||||
|
|
||||||
|
class Ability(HasName, HasGeneration):
|
||||||
|
|
||||||
|
is_main_series = models.BooleanField(default = False)
|
||||||
|
|
||||||
|
|
||||||
|
class AbilityDescription(HasLanguage, HasAbility):
|
||||||
|
|
||||||
short_effect = models.CharField(max_length=300)
|
short_effect = models.CharField(max_length=300)
|
||||||
|
|
||||||
effect = models.CharField(max_length=2000)
|
effect = models.CharField(max_length=2000)
|
||||||
|
|
||||||
|
|
||||||
class AbilityFlavorText(models.Model):
|
class AbilityFlavorText(HasLanguage, HasAbility, HasVersionGroup):
|
||||||
|
|
||||||
ability_id = models.IntegerField()
|
|
||||||
|
|
||||||
version_group_id = models.IntegerField()
|
|
||||||
|
|
||||||
language_id = models.IntegerField()
|
|
||||||
|
|
||||||
flavor_text = models.CharField(max_length=100)
|
flavor_text = models.CharField(max_length=100)
|
||||||
|
|
||||||
|
|
||||||
class AbilityName(models.Model):
|
class AbilityName(IsName, HasAbility):
|
||||||
|
pass
|
||||||
ability_id = models.IntegerField()
|
|
||||||
|
|
||||||
local_language_id = models.IntegerField()
|
|
||||||
|
|
||||||
name = models.CharField(max_length=30)
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
|
|
||||||
class Ability(models.Model):
|
|
||||||
|
|
||||||
flavor_text = models.ForeignKey(AbilityFlavorText, blank=True, null=True)
|
#################
|
||||||
|
# TYPE MODELS #
|
||||||
|
#################
|
||||||
|
|
||||||
generation = models.IntegerField()
|
class Type(HasName, HasGeneration):
|
||||||
|
|
||||||
is_main_series = models.IntegerField()
|
damage_class_id = models.IntegerField(blank = True, null = True)
|
||||||
|
|
||||||
description = models.OneToOneField(AbilityDescription, blank=True, null=True)
|
|
||||||
|
|
||||||
name = models.CharField(max_length=30)
|
class TypeName(IsName, HasType):
|
||||||
|
pass
|
||||||
|
|
||||||
names = models.ForeignKey(AbilityName, blank=True, null=True)
|
|
||||||
|
class TypeGameIndex(HasType, HasGeneration):
|
||||||
|
|
||||||
|
game_index = models.IntegerField()
|
||||||
|
|
||||||
|
|
||||||
|
class TypeEfficacy(models.Model):
|
||||||
|
|
||||||
|
damage_type_id = models.IntegerField()
|
||||||
|
|
||||||
|
target_type_id = models.IntegerField()
|
||||||
|
|
||||||
|
damage_factor = models.IntegerField()
|
||||||
|
|
Loading…
Reference in a new issue