# Generated by Django 2.0.3 on 2018-03-12 12:24

import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Article',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('aid', models.CharField(max_length=32)),
                ('slug', models.SlugField(max_length=32, null=True)),
                ('position_in_page', models.PositiveIntegerField(blank=True, null=True)),
                ('title', models.CharField(blank=True, max_length=2048, null=True)),
                ('description', models.TextField(blank=True, null=True)),
                ('content', models.TextField(blank=True, null=True)),
                ('content_html', models.TextField(blank=True, null=True)),
                ('bounding_box', django.contrib.postgres.fields.jsonb.JSONField(default='{}')),
                ('title_image', models.ImageField(blank=True, null=True, upload_to='periodicals/')),
            ],
            options={
                'ordering': ['page__number', 'position_in_page', 'aid'],
            },
        ),
        migrations.CreateModel(
            name='ArticleType',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=2048)),
            ],
            options={
                'ordering': ['title'],
            },
        ),
        migrations.CreateModel(
            name='Issue',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uid', models.CharField(max_length=32, unique=True)),
                ('slug', models.CharField(max_length=32, unique=True)),
                ('issue_date', models.DateField()),
                ('number_of_pages', models.PositiveIntegerField(blank=True, null=True)),
                ('pdf', models.FileField(null=True, upload_to='periodicals/')),
            ],
            options={
                'ordering': ['publication', 'issue_date'],
            },
        ),
        migrations.CreateModel(
            name='Page',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('height', models.PositiveIntegerField(null=True)),
                ('number', models.PositiveIntegerField()),
                ('image', models.ImageField(upload_to='periodicals/')),
                ('width', models.PositiveIntegerField(null=True)),
                ('words', django.contrib.postgres.fields.jsonb.JSONField(default='{}', null='true')),
                ('issue', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pages', to='periodicals.Issue')),
            ],
            options={
                'ordering': ['issue', 'number'],
            },
        ),
        migrations.CreateModel(
            name='Publication',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('abbreviation', models.CharField(max_length=3, unique=True)),
                ('slug', models.SlugField(max_length=3, unique=True)),
                ('title', models.CharField(blank=True, max_length=256, null=True)),
                ('description', models.TextField(blank=True, null=True)),
                ('ordering', models.PositiveIntegerField(blank=True, null=True)),
                ('title_image', models.ImageField(blank=True, null=True, upload_to='')),
            ],
            options={
                'ordering': ['ordering'],
            },
        ),
        migrations.AddField(
            model_name='issue',
            name='publication',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='issues', to='periodicals.Publication'),
        ),
        migrations.AddField(
            model_name='article',
            name='article_type',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='periodicals.ArticleType'),
        ),
        migrations.AddField(
            model_name='article',
            name='continuation_from',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='continued_from', to='periodicals.Article'),
        ),
        migrations.AddField(
            model_name='article',
            name='continuation_to',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='continues_in', to='periodicals.Article'),
        ),
        migrations.AddField(
            model_name='article',
            name='issue',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='articles_in_issue', to='periodicals.Issue'),
        ),
        migrations.AddField(
            model_name='article',
            name='page',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='articles_in_page', to='periodicals.Page'),
        ),
    ]
