# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations


def data_migration(apps, schema_editor):
    """Migration 0032 inadvertently set previously non-existent "Upload DIP to
    AtoM" values to 'None'. This fixes that.
    """
    apps.get_model('main', 'DashboardSetting').objects.filter(
        scope='upload-qubit_v0.0', value='None').update(value='')


class Migration(migrations.Migration):

    dependencies = [
        ('main', '0047_version_number'),
    ]

    operations = [
        migrations.RunPython(data_migration)
    ]

Add migration to fix "None" AtoM config issue
Add migration to fix "None" AtoM config issue

Fixes an issue introduced by migration 0032 wherein an AtoM setting that did
not exist in the previous state of the database was inadvertently created with
a value of 'None'. The migration introduced here changes those 'None's
to ''s.

Fixes #879.
