# -*- coding: utf-8 -*-
# Generated by Django 1.11.22 on 2019-08-07 12:37
from __future__ import unicode_literals

from django.db import migrations

from directory_constants import user_roles


def populate_supplier_roles(apps, schema_editor):
    Supplier = apps.get_model('supplier', 'Supplier')
    for supplier in Supplier.objects.all():
        if supplier.is_company_owner:
            supplier.role = user_roles.ADMIN
        else:
            supplier.role = user_roles.EDITOR
        supplier.save()


class Migration(migrations.Migration):

    dependencies = [
        ('supplier', '0004_supplier_role'),
    ]

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