# Generated by Django 3.0.4 on 2020-03-13 16:02

import django.core.validators
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('truck', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Driver',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('full_name', models.CharField(max_length=100, verbose_name='Full Name')),
                ('gender', models.CharField(choices=[('M', 'Male'), ('F', 'Female'), ('O', 'Others')], max_length=2, verbose_name='Gender')),
                ('cpf', models.CharField(max_length=14, unique=True, verbose_name='CPF')),
                ('cnh', models.CharField(max_length=12, unique=True, verbose_name='CNH')),
                ('cnh_type', models.CharField(choices=[('ACC', 'Category ACC'), ('A', 'Category A'), ('B', 'Category B'), ('C', 'Category C'), ('D', 'Category D'), ('E', 'Category E')], max_length=4, verbose_name='CNH Type')),
                ('telephone', models.CharField(max_length=15, verbose_name='Telephone')),
                ('age', models.PositiveSmallIntegerField(blank=True, validators=[django.core.validators.MinValueValidator(18)], verbose_name='Age')),
                ('birthday', models.DateField(verbose_name='Birth date')),
                ('created', models.DateTimeField(auto_now_add=True, verbose_name='Creation date')),
                ('updated', models.DateTimeField(auto_now_add=True, verbose_name='Update date')),
                ('has_vehicle', models.BooleanField(default=False, verbose_name='Driver has vehicle?')),
                ('is_active', models.BooleanField(default=True, verbose_name='Is active?')),
            ],
            options={
                'verbose_name': 'Driver',
                'verbose_name_plural': 'Drivers',
                'ordering': ['full_name', 'cpf'],
                'permissions': (('detail_driver', 'Can detail Driver'), ('list_driver', 'Can list Driver')),
            },
        ),
        migrations.CreateModel(
            name='Register',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', models.DateTimeField(auto_now_add=True, verbose_name='Creation date')),
                ('updated', models.DateTimeField(auto_now_add=True, verbose_name='Update date')),
                ('is_Loaded', models.BooleanField(default=False, verbose_name='Is loaded?')),
                ('driver', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='driver.Driver', verbose_name='Register Driver')),
                ('truck', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='truck.Truck', verbose_name='Register Truck')),
            ],
            options={
                'verbose_name': 'Register',
                'verbose_name_plural': 'Registers',
                'ordering': ['-created'],
                'permissions': (('detail_register', 'Can detail Register'), ('list_register', 'Can list Register')),
            },
        ),
        migrations.AddField(
            model_name='driver',
            name='registers',
            field=models.ManyToManyField(related_name='drivers', through='driver.Register', to='truck.Truck', verbose_name='Registers'),
        ),
        migrations.AddConstraint(
            model_name='driver',
            constraint=models.UniqueConstraint(fields=('cpf', 'cnh'), name='unique_driver'),
        ),
        migrations.AddConstraint(
            model_name='driver',
            constraint=models.CheckConstraint(check=models.Q(age__gte=18), name='age_gte_18'),
        ),
    ]
