# Generated by Django 2.2.8 on 2020-04-08 15:26

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


class Migration(migrations.Migration):

    dependencies = [
        ('search', '0003_auto_20200304_1410'),
        ('users', '0002_auto_20200126_1917'),
    ]

    operations = [
        migrations.CreateModel(
            name='Ownership',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('state', models.CharField(choices=[('Neuf', 'Neuf'), ('Bon état', 'Bon état'), ('Légèrement abimé', 'Légèrement abimé'), ('Très abimé', 'Très abimé')], max_length=50, null=True)),
                ('availability', models.BooleanField(null=True)),
                ('book', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='search.Book')),
            ],
        ),
        migrations.RemoveField(
            model_name='customuser',
            name='user_books',
            # field=models.ManyToManyField(related_name='owner', through='users.Ownership', to='search.Book'),
        ),
        migrations.AddField(
            model_name='customuser',
            name='user_books',
            field=models.ManyToManyField(related_name='owner', through='users.Ownership', to='search.Book'),
        ),
        migrations.AddField(
            model_name='ownership',
            name='customuser',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
        ),
        migrations.CreateModel(
            name='Borrowing',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('start_date', models.DateField(null=True)),
                ('end_date', models.DateField(null=True)),
                ('rental_request_date', models.DateField(null=True)),
                ('book', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='search.Book')),
                ('customuser', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.AddField(
            model_name='customuser',
            name='borrower',
            field=models.ManyToManyField(through='users.Borrowing', to='search.Book'),
        ),
    ]
