# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-06-04 17:50
from __future__ import unicode_literals

from django.db import migrations


def fix(category_model, description, new_validator):
    cat = category_model.objects.filter(description=description).first()
    cat.validator = new_validator
    cat.save()


def create_badges(apps, schema):
    category_model = apps.get_model('core.Badge')

    fix(category_model, "Complete 1 Mystery task", 'int(bool(user_calls.filter(task__category__slug="mystery").count()))')
    fix(category_model, "Complete 1 Stranger task", 'int(bool(user_calls.filter(task__category__slug="stranger").count()))')
    fix(category_model, "Complete 1 Geo task", 'int(bool(user_calls.filter(task__category__slug="geo").count()))')
    fix(category_model, "Complete 1 Selfie task", 'int(bool(user_calls.filter(task__category__slug="selfie").count()))')
    fix(category_model, "Complete 1 Team task", 'int(bool(user_calls.filter(task__category__slug="team").count()))')




class Migration(migrations.Migration):

    dependencies = [
        ('core', '0019_auto_20160605_1151'),
    ]

    operations = [
        migrations.RunPython(create_badges),
    ]
