# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-10-31 14:22
from __future__ import unicode_literals

from django.db import migrations


def create_votes(apps, schema_editor):
    TranscriptPhraseVote = apps.get_model(
        'transcript', 'TranscriptPhraseVote'
    )
    TranscriptPhraseCorrection = apps.get_model(
        'transcript', 'TranscriptPhraseCorrection'
    )
    corrections = TranscriptPhraseCorrection.objects.filter(
        not_an_error=True
    )
    for correction in corrections:
        if TranscriptPhraseVote.objects.filter(
            user=correction.user,
            transcript_phrase=correction.transcript_phrase
        ).count() == 0:
            TranscriptPhraseVote.objects.create(
                transcript_phrase=correction.transcript_phrase,
                user=correction.user,
                upvote=True
            )


class Migration(migrations.Migration):

    dependencies = [
        ('transcript', '0017_auto_20171031_1420'),
    ]

    operations = [
        migrations.RunPython(create_votes)
    ]

Convert 'not an error' corrections to TranscriptPhraseVote objects
Convert 'not an error' corrections to TranscriptPhraseVote objects
