# -*- coding: utf-8 -*-
# Generated by Django 1.9.8 on 2016-10-18 08:40
from __future__ import unicode_literals
from datetime import time
from django.db import migrations, models
import django.db.models.deletion

def add_weekly_time_slot(apps, schema_editor):
    WeeklyTimeSlot = apps.get_model('app', 'WeeklyTimeSlot')
    LiveCourseWeeklyTimeSlot = apps.get_model('app', 'LiveCourseWeeklyTimeSlot')

    for weekday in range(1, 8):
        for start in ((8, 0), (10, 20), (13, 30), (16, 0), (18, 30)):
            end = (start[0] + 2, start[1])
            wts = WeeklyTimeSlot(weekday=weekday, start=time(*start),
                    end=time(*end))
            wts.save()
            lc_wts = LiveCourseWeeklyTimeSlot(weeklytimeslot=wts)
            lc_wts.save()

class Migration(migrations.Migration):

    dependencies = [
        ('app', '0170_auto_20161018_1124'),
    ]

    operations = [
        migrations.CreateModel(
            name='LiveCourseWeeklyTimeSlot',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('weeklytimeslot', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.WeeklyTimeSlot')),
            ],
            options={
                'db_table': 'app_livecourse_weeklytimeslot',
                'ordering': ['weeklytimeslot__weekday', 'weeklytimeslot__start'],
            },
        ),
        migrations.RunPython(add_weekly_time_slot),
    ]
