# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-10-27 18:44
from __future__ import unicode_literals

from django.db import migrations


def create_votes(apps, schema_editor):
    Profile = apps.get_model(
        'accounts', 'Profile'
    )
    TranscriptPhraseVote = apps.get_model(
        'transcript', 'TranscriptPhraseVote'
    )
    for profile in Profile.objects.all():
        phrases = profile.considered_phrases.all()
        for phrase in phrases:
            if TranscriptPhraseVote.objects.filter(
                transcript_phrase=phrase, user=profile.user
            ).count() == 0:
                vote = TranscriptPhraseVote(
                    transcript_phrase=phrase,
                    user=profile.user,
                    upvote=True
                )
                vote.save()


class Migration(migrations.Migration):

    dependencies = [
        ('transcript', '0015_auto_20171027_1252'),
    ]

    operations = [
        migrations.RunPython(create_votes)
    ]

Convert un-downvoted considered phrases to upvotes
Convert un-downvoted considered phrases to upvotes
