def move_custom_slides_to_topics(apps, schema_editor):
    """
    Move all custom slides to new topic model.
    """
    ContentType = apps.get_model('contenttypes', 'ContentType')
    CustomSlide = apps.get_model('core', 'CustomSlide')
    Item = apps.get_model('agenda', 'Item')
    Topic = apps.get_model('topics', 'Topic')
    content_type_custom_slide = ContentType.objects.get_for_model(CustomSlide)
    content_type_topic = ContentType.objects.get_for_model(Topic)
    for custom_slide in CustomSlide.objects.all():
        topic = Topic.objects.create(title=custom_slide.title, text=
            custom_slide.text)
        topic.attachments.add(*custom_slide.attachments.all())
        item = Item.objects.get(object_id=custom_slide.pk, content_type=
            content_type_custom_slide)
        item.object_id = topic.pk
        item.content_type = content_type_topic
        item.save(skip_autoupdate=True)
    CustomSlide.objects.all().delete()
    content_type_custom_slide.delete()
