# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2017-02-18 16:49
#
# Builds two to-do lists for counting the characters
#
#########################################################
from __future__ import unicode_literals

from django.db import migrations


def create_list(apps) -> None:
    Page_w_chars = apps.get_model('calligraphy', 'ToCountCharactersWBoxes')
    Page_wo_chars = apps.get_model('calligraphy', 'toCountCharactersWoBoxes')
    Chars = apps.get_model('calligraphy', 'Character')
    
    for page in apps.get_model('calligraphy', 'Page').objects.all():
        if len(Chars.objects.filter(parent_page=page.id)) == 0:
            new_page = Page_wo_chars(toCheck=page)
        else:
            new_page = Page_w_chars(toCheck=page)
        new_page.save()


def do_stuff(apps, schemd_editor) -> None:
    create_list(apps)

class Migration(migrations.Migration):

    dependencies = [
        ('calligraphy', '0068_tocountcharacterswboxes_tocountcharacterswoboxes'),
    ]

    operations = [ migrations.RunPython(do_stuff)
    ]
