# Generated by Django 2.2.23 on 2021-09-24 22:29

from django.db import migrations, models
import django.db.models.deletion

def copy_urls(apps, schema_editor):
    SeeAlso = apps.get_model("library", "SeeAlso")
    WebLink = apps.get_model("library", "WebLink")
    for oldlink in SeeAlso.objects.filter(url__isnull=False):
        newlink, _ = WebLink.objects.get_or_create(
            entry=oldlink.source_entry,
            url=oldlink.url,
        )

class Migration(migrations.Migration):

    dependencies = [
        ('library', '0035_entrymedia_entrypurpose_librarypersona'),
    ]

    operations = [
        migrations.AlterModelOptions(
            name='seealso',
            options={'verbose_name': 'Related Entry', 'verbose_name_plural': 'Related Entries'},
        ),
        migrations.AddField(
            model_name='entrymedia',
            name='asthumb',
            field=models.BooleanField(default=False, verbose_name='Use for thumbnail'),
        ),
        migrations.AddField(
            model_name='seealso',
            name='comment',
            field=models.CharField(blank=True, max_length=256, null=True),
        ),
        migrations.CreateModel(
            name='WebLink',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('url', models.URLField()),
                ('comment', models.CharField(blank=True, max_length=256, null=True)),
                ('entry', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='weblinks', to='library.Entry')),
            ],
            options={
                'verbose_name': 'Web Link',
            },
        ),
        migrations.RunPython(copy_urls)
    ]
