# -*- coding: utf-8 -*-
# Generated by Django 1.9.8 on 2017-03-13 21:41
from __future__ import unicode_literals

from django.db import migrations, models
import wagtail.wagtailcore.fields

from cpm_generic.migration_utils import get_content_type, add_subpage, remove_subpage


def add_partners_page(apps, schema_editor):
    HomePage = apps.get_model('home.HomePage')
    PartnersPage = apps.get_model('partners.PartnersPage')
    Season = apps.get_model('cpm_data.Season')

    partners_page_ct = get_content_type(apps, 'partners', 'partnerspage')

    homepage = HomePage.objects.get(slug='home')
    season = Season.objects.get(name_en='2017')

    #import pdb

    #pdb.set_trace()

    add_subpage(
        homepage,
        PartnersPage,
        content_type=partners_page_ct,
        title=u'CPM Partners',
        slug='partners',
        name_en=u'Partners',
        name_be=u'Партнёры',
        name_ru=u'Партнеры',
        entry_en=u'<i>Cinema Perpetuum Mobile</i> is a non-profit, independent project which keeps on expenses and aspirations of the organizers. At the same time international nature of the event, cultural resonance provides fertile ground for collaboration with business and public organizations.',
        entry_be=u'<i>Cinema Perpetuum Mobile</i> - некамерцыйны, незалежны праект, які трымаецца на імкненнях і сродках арганізатараў. У той жа час чакаемы культурны рэзананс падзеі, яе міжнародны характар, актыўныя зацікаўленнасці, ствараюць выдатную глебу для супрацоўніцтва з камерцыйнымі і грамадскімі ўстановамі.',
        entry_ru=u'<i>Cinema Perpetuum Mobile</i> - некоммерческий, независимый проект, который держится на устремлениях и расходах организаторов. В то же время международный характер события, его культурный резонанс, заинтересованности, создают благоприятную почву для сотрудничества с коммерческими и общественными организациями.',
        season=season
    )


def remove_partners_page(apps, schema_editor):
    HomePage = apps.get_model('home.HomePage')
    PartnersPage = apps.get_model('partners.PartnersPage')

    partners_page_ct = get_content_type(apps, 'partners', 'partnerspage')

    homepage = HomePage.objects.get(slug='home')
    remove_subpage(
        homepage,
        PartnersPage,
        content_type=partners_page_ct,
        slug='partners'
    )


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('home', '0002_create_homepage'),
        ('partners', '0001_initial'),
    ]


    operations = [
        migrations.RunPython(add_partners_page, remove_partners_page),
    ]

@@ -74,117 +74,34 @@
 rom 
-__future__ import unicode_literals%0A%0Afrom django.db import migrations, models%0Aimport wagtail.wagtailcore.field
+django.db import migration
 s%0A%0Af
@@ -139,16 +139,17 @@
  import 
+(
 get_cont
@@ -166,24 +166,65 @@
 add_subpage,
+%0A                                        
  remove_subp
@@ -226,16 +226,17 @@
 _subpage
+)
 %0A%0A%0Adef a
@@ -605,47 +605,8 @@
 ')%0A%0A
-    #import pdb%0A%0A    #pdb.set_trace()%0A%0A
     
@@ -1140,16 +1140,29 @@
 tions.',
+  # noqa:E501
 %0A       
@@ -1474,16 +1474,29 @@
 %D0%BE%D0%B2%D0%B0%D0%BC%D1%96.',
+  # noqa:E501
 %0A       
@@ -1821,16 +1821,29 @@
 %D1%86%D0%B8%D1%8F%D0%BC%D0%B8.',
+  # noqa:E501
 %0A       
@@ -2442,17 +2442,16 @@
 %0A    %5D%0A%0A
-%0A
     oper

Fix flake8 violations in migration partners/0002