# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-15 11:41
from __future__ import unicode_literals
from django.db import migrations


def forwards(apps, schema_editor):
    SocialApp = apps.get_registered_model('socialaccount', 'SocialApp')
    Site = apps.get_registered_model('sites', 'Site')
    site = Site.objects.filter().first()
    facebook = SocialApp.objects.filter(provider="facebook").first()
    instagram = SocialApp.objects.filter(provider="instagram").first()
    if site:
        site.domain = "tangosquadmilano.it"
        site.name = "tangosquadmilano.it"
    else:
        site = Site(domain="tangosquadmilano.it",
                    name="tangosquadmilano.it")
    site.save()
    if facebook:
        facebook.client_id = "174856216338903"
        facebook.secret = "0329f48c5790254a0c9f0832305107fd"
        facebook.sites = [site]
    else:
        facebook = SocialApp(provider="facebook",
                             name="Facebook",
                             client_id="174856216338903",
                             secret="0329f48c5790254a0c9f0832305107fd",
                             key="",)
    facebook.save()
    facebook.sites = [site]
    facebook.save()
    if instagram:
        instagram.client_id = "33f46bd5786844a19c7abe3257aef171"
        instagram.secret = "d8dca9da1cd24b3784c2c809a1ef3ffc"
        instagram.sites = [1]
    else:
        instagram = SocialApp(provider="instagram",
                              name="Instagram",
                              client_id="33f46bd5786844a19c7abe3257aef171",
                              secret="d8dca9da1cd24b3784c2c809a1ef3ffc",
                              key="",)
        instagram.save()
        instagram.sites = [site]
        instagram.save()


class Migration(migrations.Migration):

    dependencies = [('socialaccount', '0001_initial'),
                    ('account', '0001_initial'),
                    ('adidas', '0001_initial'), ]

    operations = [migrations.RunPython(forwards)]
