# -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2017-11-17 09:32
from __future__ import unicode_literals

from datetime import date

from django.db import migrations, models

FESTIVALS = [
    {
        "name": "World Day of Peace",
        "description": "The World Day of Peace is a feast day of the Roman Catholic Church dedicated to universal peace, held on 1 January, the Solemnity of Mary, Mother of God.",
        "festival_date": date(2018, 1, 20),
        "colors": "white and red",
        "slug": "world-peace-day",
    },
    {
        "name": "Divine Mercy Sunday",
        "description": "Divine Mercy Sunday is celebrated on the Sunday after Easter, the Octave of Easter, observed by Roman Catholic as well as some Anglicans.",
        "festival_date":date(2018, 5, 21),
        "colors": "Green and white",
        "slug": "divine-mercy",
    },
    {
        "name": "Memorial of the Holy Guardian Angels",
        "description": "The Memorial of the Holy Guardian Angels is a memorial of the Catholic Church officially observed on 2 October.",
        "festival_date": date(2018, 10, 2),
        "colors": "cream and white",
        "slug": "holy-guardian-angels",
    },
]

def add_festival_data(apps, schema_editor):
    Festival = apps.get_model('people', 'Festival')
    for festival in FESTIVALS:
        festival_object = Festival.objects.create(
            name=festival['name'],
            description=festival['description'],
            festival_date=festival['festival_date'],
            colors=festival['colors'],
            slug=festival['slug'])

def remove_festival_data(apps, schema_editor):
    Festival = apps.get_model('people', 'Festival')
    for festival in FESTIVALS:
        festival_object = Festival.objects.get(slug=festival['slug'])
        festival_object.delete()


class Migration(migrations.Migration):

    dependencies = [
        ('people', '0004_community_data'),
    ]

    operations = [
        migrations.RunPython(
            add_festival_data,
            remove_festival_data)
    ]
