# Generated by Django 2.1.15 on 2020-07-01 13:42

from django.db import migrations
from users.managers import RoleManager

STUDENT_4Y_ISBN = '978-3-0355-1397-4'
TEACHER_1Y_ISBN = '978-3-0355-1823-8'


def add_isbn_to_license(apps, schema_editor):
    License = apps.get_model('users', 'License')
    for existing_license in License.objects.all():
        if existing_license.for_role.key == RoleManager.TEACHER_KEY:
            existing_license.isbn = TEACHER_1Y_ISBN
        else:
            existing_license.isbn = STUDENT_4Y_ISBN

        existing_license.save()


class Migration(migrations.Migration):

    dependencies = [
        ('users', '0021_license_isbn'),
    ]

    operations = [
        migrations.RunPython(add_isbn_to_license, migrations.RunPython.noop),
    ]
