# Generated by Django 3.0 on 2019-12-27 15:12

from django.db import migrations

from users.serializers import UserSerializer


def forwards_func(apps, schema_editor):
    serializer = UserSerializer(data={'email': 'anonymous@mail.com', 'password': '1111', 'first_name': 'Anonymous',
                                      'last_name': 'Anonymous'})
    serializer.is_valid(raise_exception=True)
    serializer.save()
    Student = apps.get_model('users', 'Student')
    Student.objects.create(user=apps.get_model('users', 'User').objects.get(email='anonymous@mail.com'))


def reverse_func(apps, schema_editor):
    User = apps.get_model('users', 'User')
    Student = apps.get_model('users', 'Student')
    Student.objects.get(user__email='anonymous@mail.com').delete()
    User.objects.get(email='anonymous@mail.com').delete()


class Migration(migrations.Migration):
    dependencies = [
        ('analytics', '0002_solvedtest_is_checked'),
    ]

    operations = [
        migrations.RunPython(forwards_func, reverse_func),
    ]
