# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2018-01-13 20:03
from __future__ import unicode_literals

from django.db import migrations


def generate_full_staffer_names(apps, schema_editor):
    Staffer = apps.get_model('editorial_staff', 'Staffer')

    for staffer in Staffer.objects.all():
        if staffer.full_name is None:
            if staffer.first_name:
                staffer.full_name = '{} {}'.format(
                    staffer.first_name,
                    staffer.last_name
                )
            else:
                staffer.full_name = staffer.last_name
            staffer.save()


class Migration(migrations.Migration):

    dependencies = [
        ('editorial_staff', '0006_staffer_full_name'),
    ]

    operations = [
        migrations.RunPython(generate_full_staffer_names),
    ]
