"""Seed Sign, Planet, AspectType, and HouseLabel reference tables."""
from django.db import migrations

# (order, name, symbol, element, modality, start_degree)
SIGNS = [
    (0,  'Aries',       '♈', 'Fire',  'Cardinal',   0.0),
    (1,  'Taurus',      '♉', 'Earth', 'Fixed',      30.0),
    (2,  'Gemini',      '♊', 'Air',   'Mutable',    60.0),
    (3,  'Cancer',      '♋', 'Water', 'Cardinal',   90.0),
    (4,  'Leo',         '♌', 'Fire',  'Fixed',     120.0),
    (5,  'Virgo',       '♍', 'Earth', 'Mutable',   150.0),
    (6,  'Libra',       '♎', 'Air',   'Cardinal',  180.0),
    (7,  'Scorpio',     '♏', 'Water', 'Fixed',     210.0),
    (8,  'Sagittarius', '♐', 'Fire',  'Mutable',   240.0),
    (9,  'Capricorn',   '♑', 'Earth', 'Cardinal',  270.0),
    (10, 'Aquarius',    '♒', 'Air',   'Fixed',     300.0),
    (11, 'Pisces',      '♓', 'Water', 'Mutable',   330.0),
]

# (order, name, symbol)
PLANETS = [
    (0, 'Sun',     '☉'),
    (1, 'Moon',    '☽'),
    (2, 'Mercury', '☿'),
    (3, 'Venus',   '♀'),
    (4, 'Mars',    '♂'),
    (5, 'Jupiter', '♃'),
    (6, 'Saturn',  '♄'),
    (7, 'Uranus',  '♅'),
    (8, 'Neptune', '♆'),
    (9, 'Pluto',   '♇'),
]

# (name, symbol, angle, orb) — mirrors ASPECTS in pyswiss/apps/charts/calc.py
ASPECT_TYPES = [
    ('Conjunction',    '☌',   0,   8.0),
    ('Semisextile',    '⚺',  30,   4.0),
    ('Semisquare',     '∠',  45,   4.0),
    ('Sextile',        '⚹',  60,   6.0),
    ('Square',         '□',  90,   8.0),
    ('Trine',          '△', 120,   8.0),
    ('Sesquiquadrate', '⊼', 135,   4.0),
    ('Quincunx',       '⚻', 150,   5.0),
    ('Opposition',     '☍', 180,  10.0),
]

# (number, name, keywords)
HOUSE_LABELS = [
    (1,  'Self',         'identity, appearance, first impressions'),
    (2,  'Worth',        'possessions, values, finances'),
    (3,  'Education',    'communication, siblings, short journeys'),
    (4,  'Family',       'home, roots, ancestry'),
    (5,  'Creation',     'creativity, romance, children, pleasure'),
    (6,  'Ritual',       'service, health, daily routines'),
    (7,  'Cooperation',  'partnerships, marriage, open enemies'),
    (8,  'Regeneration', 'transformation, shared resources, death'),
    (9,  'Enterprise',   'philosophy, travel, higher learning'),
    (10, 'Career',       'public life, reputation, authority'),
    (11, 'Reward',       'friends, groups, aspirations'),
    (12, 'Reprisal',     'hidden matters, karma, self-undoing'),
]


def seed(apps, schema_editor):
    Sign       = apps.get_model('epic', 'Sign')
    Planet     = apps.get_model('epic', 'Planet')
    AspectType = apps.get_model('epic', 'AspectType')
    HouseLabel = apps.get_model('epic', 'HouseLabel')

    for order, name, symbol, element, modality, start_degree in SIGNS:
        Sign.objects.create(order=order, name=name, symbol=symbol,
                            element=element, modality=modality, start_degree=start_degree)

    for order, name, symbol in PLANETS:
        Planet.objects.create(order=order, name=name, symbol=symbol)

    for name, symbol, angle, orb in ASPECT_TYPES:
        AspectType.objects.create(name=name, symbol=symbol, angle=angle, orb=orb)

    for number, name, keywords in HOUSE_LABELS:
        HouseLabel.objects.create(number=number, name=name, keywords=keywords)


class Migration(migrations.Migration):

    dependencies = [
        ('epic', '0004_seed_earthman_deck'),
    ]

    operations = [
        migrations.RunPython(seed, migrations.RunPython.noop),
    ]
