@@ -0,0 +1,1290 @@
+# -*- coding: utf-8 -*-%0A# Generated by Django 1.11.10 on 2018-03-06 11:49%0Afrom __future__ import unicode_literals%0A%0Afrom django.db import migrations%0Afrom django.template.defaultfilters import striptags%0Afrom app.templatetags.custom_filters import replace_entities%0A%0AMAIN_CTS = %5B9, 13, 14, 16, 36, 106%5D%0A%0A%0Adef cp_summaries_to_wells(apps, schema_editor):%0A    Node = apps.get_model('arm_wells', 'Node')%0A    Content = apps.get_model('base', 'Content')%0A    content_nodes = Node.objects.filter(content_type_id__in=MAIN_CTS)%0A    content_map = %7Bitem.id: item.long_summary or item.summary_caption for item in%0A        Content.objects.filter(id__in=content_nodes.values_list('object_id', flat=True))%7D%0A    for i, item in enumerate(content_nodes):%0A        if i %25 1000 == 0:%0A            print('On item %25d' %25 i)%0A        try:%0A            item.well_summary = replace_entities(striptags(content_map%5Bitem.object_id%5D))%0A        except KeyError:%0A            print('MISSED on id %25d' %25 item.object_id)%0A        else:%0A            item.save()%0A%0A%0Aclass Migration(migrations.Migration):%0A%0A    dependencies = %5B%0A        ('arm_wells', '0002_node_well_summary'),%0A        ('base', '0004_migrate_bylines'),%0A    %5D%0A%0A    operations = %5B%0A        migrations.RunPython(cp_summaries_to_wells, reverse_code=migrations.RunPython.noop)%0A    %5D%0A

Add data migration