<reponame>josperdom1/AII<gh_stars>0
# Generated by Django 2.2.7 on 2019-11-21 14:21

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


def load_categories():
    category = apps.get_model('films', 'Category')
    cats = ['unknown', 'Action', 'Adventure',
            'Animation', 'Children\'s', 'Comedy', 'Crime', 'Documental', 'Drama', 'Fantasy', 'Film-Noir',
            'Horror', 'Musical', 'Mystery', 'Romance', 'Sci-Fi', 'Thriller', 'War', 'Western']
    for cat in cats:
        new_cat = category.create(name=cat)
        new_cat.save()


class Migration(migrations.Migration):
    initial = True

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

    operations = [

        migrations.CreateModel(
            name='Category',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.TextField(max_length=500)),
            ],
        ),
        migrations.CreateModel(
            name='Director',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.TextField(blank=True, max_length=500)),
                ('surname', models.TextField(max_length=500)),
                ('biography', models.TextField(blank=True, max_length=500)),
                (
                'user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='StandardUser',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.TextField(max_length=500)),
                ('surname', models.TextField(max_length=500)),
                ('birth_date', models.DateField(blank=True, null=True)),
                ('categories', models.ManyToManyField(to='films.Category')),
                (
                'user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Film',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=100, unique=True)),
                ('year', models.PositiveSmallIntegerField(validators=[django.core.validators.MinValueValidator(1900),
                                                                      django.core.validators.MaxValueValidator(2019)],
                                                          verbose_name='Year')),
                ('summary', models.TextField(verbose_name='Summary')),
                ('categories', models.ManyToManyField(to='films.Category')),
                ('director', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='films.Director')),
            ],

        ),

        migrations.RunPython(load_categories),
    ]

# Generated by Django 2.2.7 on 2019-11-21 14:21

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


def load_categories():
    category = apps.get_model('films', 'Category')
    cats = ['unknown', 'Action', 'Adventure',
            'Animation', 'Children\'s', 'Comedy', 'Crime', 'Documental', 'Drama', 'Fantasy', 'Film-Noir',
            'Horror', 'Musical', 'Mystery', 'Romance', 'Sci-Fi', 'Thriller', 'War', 'Western']
    for cat in cats:
        new_cat = category.create(name=cat)
        new_cat.save()


class Migration(migrations.Migration):
    initial = True

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

    operations = [

        migrations.CreateModel(
            name='Category',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.TextField(max_length=500)),
            ],
        ),
        migrations.CreateModel(
            name='Director',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.TextField(blank=True, max_length=500)),
                ('surname', models.TextField(max_length=500)),
                ('biography', models.TextField(blank=True, max_length=500)),
                (
                'user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='StandardUser',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.TextField(max_length=500)),
                ('surname', models.TextField(max_length=500)),
                ('birth_date', models.DateField(blank=True, null=True)),
                ('categories', models.ManyToManyField(to='films.Category')),
                (
                'user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Film',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=100, unique=True)),
                ('year', models.PositiveSmallIntegerField(validators=[django.core.validators.MinValueValidator(1900),
                                                                      django.core.validators.MaxValueValidator(2019)],
                                                          verbose_name='Year')),
                ('summary', models.TextField(verbose_name='Summary')),
                ('categories', models.ManyToManyField(to='films.Category')),
                ('director', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='films.Director')),
            ],

        ),

        migrations.RunPython(load_categories),
    ]
# Generated by Django 2.2.7 on 2019-11-21 14:21