# Generated by Django 2.1.3 on 2018-11-05 15:49

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


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='AllowedUsersRule',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('all_users', models.BooleanField(default=False, verbose_name='All users?')),
                ('users', models.ManyToManyField(blank=True, to=settings.AUTH_USER_MODEL, verbose_name='Users')),
            ],
            options={
                'verbose_name': 'Allowed User Rule',
                'verbose_name_plural': 'Allowed User Rules',
            },
        ),
        migrations.CreateModel(
            name='Coupon',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(default=django_simple_coupons.helpers.get_random_code, max_length=12, unique=True, verbose_name='Coupon Code')),
                ('times_used', models.IntegerField(default=0, editable=False, verbose_name='Times used')),
                ('created', models.DateTimeField(editable=False, verbose_name='Created')),
            ],
        ),
        migrations.CreateModel(
            name='CouponUser',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('times_used', models.IntegerField(default=0, editable=False, verbose_name='Times used')),
                ('coupon', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_simple_coupons.Coupon', verbose_name='Coupon')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='User')),
            ],
            options={
                'verbose_name': 'Coupon User',
                'verbose_name_plural': 'Coupon Users',
            },
        ),
        migrations.CreateModel(
            name='Discount',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('value', models.IntegerField(default=0, verbose_name='Value')),
                ('is_percentage', models.BooleanField(default=False, verbose_name='Is percentage?')),
            ],
            options={
                'verbose_name': 'Discount',
                'verbose_name_plural': 'Discounts',
            },
        ),
        migrations.CreateModel(
            name='MaxUsesRule',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('max_uses', models.BigIntegerField(default=0, verbose_name='Maximum uses')),
                ('is_infinite', models.BooleanField(default=False, verbose_name='Infinite uses?')),
                ('uses_per_user', models.IntegerField(default=1, verbose_name='Uses per user')),
            ],
            options={
                'verbose_name': 'Max Uses Rule',
                'verbose_name_plural': 'Max Uses Rules',
            },
        ),
        migrations.CreateModel(
            name='Ruleset',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('allowed_users', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_simple_coupons.AllowedUsersRule', verbose_name='Allowed users rule')),
                ('max_uses', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_simple_coupons.MaxUsesRule', verbose_name='Max uses rule')),
            ],
            options={
                'verbose_name': 'Ruleset',
                'verbose_name_plural': 'Rulesets',
            },
        ),
        migrations.CreateModel(
            name='ValidityRule',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('expiration_date', models.DateTimeField(verbose_name='Expiration date')),
                ('is_active', models.BooleanField(default=False, verbose_name='Is active?')),
            ],
            options={
                'verbose_name': 'Validity Rule',
                'verbose_name_plural': 'Validity Rules',
            },
        ),
        migrations.AddField(
            model_name='ruleset',
            name='validity',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_simple_coupons.ValidityRule', verbose_name='Validity rule'),
        ),
        migrations.AddField(
            model_name='coupon',
            name='discount',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_simple_coupons.Discount'),
        ),
        migrations.AddField(
            model_name='coupon',
            name='ruleset',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_simple_coupons.Ruleset', verbose_name='Ruleset'),
        ),
    ]
