# Generated by Django 3.0.7 on 2020-07-18 13:09

import bookflixapp.models
from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='Autor',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('nombre', models.CharField(max_length=50)),
                ('apellido', models.CharField(default='', max_length=50)),
            ],
            options={
                'verbose_name_plural': 'Autores',
                'ordering': ['apellido', 'nombre'],
            },
        ),
        migrations.CreateModel(
            name='Editorial',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('nombre', models.CharField(max_length=200)),
            ],
            options={
                'verbose_name_plural': 'Editoriales',
                'ordering': ['nombre'],
            },
        ),
        migrations.CreateModel(
            name='Genero',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('nombre', models.CharField(max_length=25, unique=True)),
            ],
            options={
                'verbose_name_plural': 'Generos',
                'ordering': ['nombre'],
            },
        ),
        migrations.CreateModel(
            name='Libro',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('titulo', models.CharField(max_length=200)),
                ('nropaginas', models.PositiveIntegerField(default=0, validators=[django.core.validators.MinValueValidator(1)], verbose_name='Numero de paginas')),
                ('nrocapitulos', models.PositiveIntegerField(default=0, validators=[django.core.validators.MinValueValidator(1)], verbose_name='Numero de capitulos')),
                ('isbn', models.CharField(max_length=13, unique=True, validators=[django.core.validators.RegexValidator('^(\\d{10}|\\d{13})$', 'El numero debe tener 10 o 13 digitos numericos')], verbose_name='ISBN')),
                ('agnoedicion', models.DateField(verbose_name='Año de edicion')),
                ('contador', models.PositiveIntegerField(default=0, editable=False, verbose_name='Veces leido')),
                ('subido', models.DateTimeField(auto_now_add=True, verbose_name='Fecha de carga')),
                ('texto', models.TextField(default='NONE', max_length=1000, verbose_name='Texto')),
                ('imagen', models.ImageField(default='default.jpg', null=True, upload_to=bookflixapp.models.Libro.content_file_name, verbose_name='Imagen')),
                ('autor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bookflixapp.Autor')),
                ('editorial', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bookflixapp.Editorial')),
                ('genero', models.ManyToManyField(to='bookflixapp.Genero')),
            ],
            options={
                'verbose_name_plural': 'Libros',
                'ordering': ['-subido', '-contador', 'titulo', '-agnoedicion', 'isbn'],
            },
        ),
        migrations.CreateModel(
            name='Novedad',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('titulo', models.CharField(max_length=100)),
                ('texto', models.TextField()),
                ('creacion', models.DateTimeField(auto_now_add=True, verbose_name='Creacion')),
            ],
            options={
                'verbose_name_plural': 'Novedades',
                'ordering': ['-creacion'],
            },
        ),
        migrations.CreateModel(
            name='Usuario',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('tarjeta', models.CharField(max_length=16, validators=[django.core.validators.RegexValidator('^(\\d{16})$', 'Debe introducir un numero de 16 digitos')], verbose_name='Tarjeta de credito')),
                ('fecha_de_nacimiento', models.DateField(verbose_name='Fecha de nacimiento')),
                ('cantPerfiles', models.IntegerField(default=2)),
                ('is_premium', models.BooleanField(default=False)),
                ('user', models.OneToOneField(default='', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name_plural': 'Usuarios',
                'ordering': ['user__email', 'fecha_de_nacimiento'],
            },
        ),
        migrations.CreateModel(
            name='Trailer',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('titulo', models.CharField(default='NONE', max_length=200, verbose_name='Titulo')),
                ('imagen', models.ImageField(blank=True, default='default.jpg', null=True, upload_to=bookflixapp.models.Trailer.content_file_name, verbose_name='Imagen')),
                ('texto', models.TextField(default='NONE', max_length=1000, verbose_name='Texto')),
                ('creacion', models.DateTimeField(auto_now_add=True, verbose_name='Creacion')),
                ('libro', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='bookflixapp.Libro')),
            ],
            options={
                'verbose_name_plural': 'Trailers',
                'ordering': ['-creacion'],
            },
        ),
        migrations.CreateModel(
            name='Perfil',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('username', models.CharField(max_length=20, verbose_name='Nombre de usuario')),
                ('selected', models.BooleanField(default=True, verbose_name='Perfil seleccionado')),
                ('favoritos', models.ManyToManyField(related_name='favoritos', to='bookflixapp.Libro', verbose_name='Favoritos')),
                ('historial', models.ManyToManyField(related_name='historial', to='bookflixapp.Libro', verbose_name='Historial')),
                ('usuario', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='bookflixapp.Usuario')),
            ],
            options={
                'verbose_name_plural': 'Perfiles',
                'ordering': ['-selected'],
            },
        ),
        migrations.CreateModel(
            name='Comentario',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('texto', models.TextField(max_length=1000, validators=[django.core.validators.MinLengthValidator(20)], verbose_name='Texto del comentario')),
                ('fecha', models.DateTimeField(auto_now_add=True, verbose_name='Fecha del comentario')),
                ('libro', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='bookflixapp.Libro', verbose_name='Libro del comentario')),
                ('perfil', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='bookflixapp.Perfil', verbose_name='Perfil del comentario')),
            ],
            options={
                'ordering': ['-fecha'],
            },
        ),
        migrations.CreateModel(
            name='Capitulo',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('numero', models.PositiveIntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(1)], verbose_name='Numero del capitulo')),
                ('nropaginas', models.PositiveIntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(1)], verbose_name='Numero de paginas')),
                ('pdf', models.FileField(blank=True, null=True, upload_to=bookflixapp.models.Capitulo.content_file_name, validators=[django.core.validators.FileExtensionValidator(['pdf'], 'Solo se permiten archivos pdf')])),
                ('libro', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bookflixapp.Libro')),
            ],
            options={
                'verbose_name_plural': 'Capitulos',
                'ordering': ['numero'],
                'unique_together': {('libro', 'numero')},
            },
        ),
        migrations.CreateModel(
            name='Calificacion',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('nota', models.PositiveIntegerField(default=0, editable=False, validators=[django.core.validators.MinValueValidator(0)], verbose_name='Calificacion')),
                ('libro', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to='bookflixapp.Libro')),
                ('perfil', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to='bookflixapp.Perfil')),
            ],
            options={
                'verbose_name_plural': 'Calificaciones',
                'unique_together': {('libro', 'perfil')},
            },
        ),
    ]
