# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2020-01-14 09:33
from __future__ import unicode_literals

from django.db import migrations
from django.db import migrations, connection
from bluebottle.clients import properties


def migrate_settings(apps, schema_editor):
    Client = apps.get_model('clients', 'Client')
    MemberPlatformSettings = apps.get_model('members', 'MemberPlatformSettings')

    tenant = Client.objects.get(schema_name=connection.tenant.schema_name)

    properties.set_tenant(tenant)

    (settings, _) = MemberPlatformSettings.objects.get_or_create()

    try:
        settings.closed = properties.CLOSED_SITE
    except AttributeError:
        pass

    try:
        if properties.TOKEN_AUTH:
            settings.login_methods = ['sso']
    except AttributeError:
        pass

    settings.save()


class Migration(migrations.Migration):

    dependencies = [
        ('members', '0033_auto_20200114_1050'),
    ]

    operations = [
        migrations.RunPython(migrate_settings)
    ]

@@ -768,11 +768,11 @@
 = %5B'
-sso
+SSO
 '%5D%0A 

Fix migration