# Generated by Django 4.1.2 on 2022-11-10 18:03

import book_manager.validators
from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import django_extensions.db.fields


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Author',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')),
                ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')),
                ('first_name', models.CharField(max_length=255, verbose_name='First name')),
                ('last_name', models.CharField(max_length=255, verbose_name='Last name')),
                ('middle_name', models.CharField(blank=True, default=None, max_length=255, null=True, verbose_name='Middle name')),
                ('full_name', models.CharField(max_length=255, unique=True, verbose_name='Full name')),
            ],
            options={
                'verbose_name': 'author',
                'verbose_name_plural': 'authors',
            },
        ),
        migrations.CreateModel(
            name='Binding',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(help_text='Binding type', max_length=128, verbose_name='Binding type')),
            ],
            options={
                'verbose_name': 'binding',
                'verbose_name_plural': 'bindings',
            },
        ),
        migrations.CreateModel(
            name='Book',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')),
                ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')),
                ('title', models.CharField(help_text='The title of the book', max_length=255, unique=True, verbose_name='Book Title')),
                ('slug', django_extensions.db.fields.AutoSlugField(blank=True, editable=False, help_text='Used in the URL for the book. Must be unique.', populate_from='title', unique=True, verbose_name='Slug')),
                ('isbn', models.CharField(blank=True, default=None, max_length=16, null=True, verbose_name='ISBN')),
                ('isbn13', models.CharField(blank=True, default=None, max_length=16, null=True, verbose_name='ISBN')),
                ('num_pages', models.PositiveIntegerField(blank=True, default=None, null=True, verbose_name='Num Pages')),
                ('year_published', models.IntegerField(blank=True, default=None, null=True, verbose_name='Year Published')),
                ('original_publication_year', models.IntegerField(blank=True, default=None, null=True, verbose_name='Original Publication Year')),
            ],
            options={
                'verbose_name': 'book',
                'verbose_name_plural': 'books',
            },
        ),
        migrations.CreateModel(
            name='Publisher',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')),
                ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')),
                ('name', models.CharField(help_text='Publisher name', max_length=255, verbose_name='Publisher name')),
            ],
            options={
                'verbose_name': 'publisher',
                'verbose_name_plural': 'publishers',
            },
        ),
        migrations.CreateModel(
            name='Shelf',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(help_text='Name of a shelf on which books can live', max_length=128, verbose_name='Shelf name')),
                ('reader', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='shelves', to=settings.AUTH_USER_MODEL, verbose_name='Reader')),
            ],
            options={
                'verbose_name': 'shelf',
                'verbose_name_plural': 'shelves',
            },
        ),
        migrations.CreateModel(
            name='Reading',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')),
                ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')),
                ('rating', models.PositiveIntegerField(default=0, validators=[django.core.validators.MaxValueValidator(5), django.core.validators.MinValueValidator(0)], verbose_name='Rating')),
                ('private_notes', models.TextField(blank=True, default=None, help_text='Private notes that only you can see', null=True, validators=[book_manager.validators.NoHTMLValidator()], verbose_name='Private Notes')),
                ('review', models.TextField(blank=True, default=None, help_text='Notes that anyone can see', null=True, validators=[book_manager.validators.NoHTMLValidator()], verbose_name='Review')),
                ('read_count', models.PositiveIntegerField(help_text="How many times you've read this book", verbose_name='Read count')),
                ('date_added', models.DateField(help_text='Date this book was added to your reading list', verbose_name='Date added')),
                ('date_read', models.DateField(default=None, help_text='Date you first read this book', null=True, verbose_name='Date read')),
                ('book', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='readings', to='book_manager.book')),
                ('reader', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='readings', to=settings.AUTH_USER_MODEL, verbose_name='Reader')),
                ('shelf', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='readings', to='book_manager.shelf')),
            ],
            options={
                'verbose_name': 'reading',
                'verbose_name_plural': 'readings',
            },
        ),
        migrations.CreateModel(
            name='BookAuthor',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('order', models.PositiveIntegerField(default=1, verbose_name='Author order')),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='book_manager.author', verbose_name='Author')),
                ('book', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='book_manager.book')),
            ],
            options={
                'verbose_name': 'book author',
                'verbose_name_plural': 'book authors',
                'unique_together': {('book', 'author', 'order')},
            },
        ),
        migrations.AddField(
            model_name='book',
            name='authors',
            field=models.ManyToManyField(related_name='books', through='book_manager.BookAuthor', to='book_manager.author', verbose_name='Authors'),
        ),
        migrations.AddField(
            model_name='book',
            name='binding',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='books', to='book_manager.binding'),
        ),
        migrations.AddField(
            model_name='book',
            name='publisher',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='books', to='book_manager.publisher'),
        ),
        migrations.AddField(
            model_name='book',
            name='readers',
            field=models.ManyToManyField(related_name='books', through='book_manager.Reading', to=settings.AUTH_USER_MODEL, verbose_name='Readers'),
        ),
    ]
