# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2019-01-20 23:39
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import preferences.models
import re2o.mixins


def create_defaults(apps, schema_editor):
    CotisationsOption = apps.get_model("preferences", "CotisationsOption")
    CotisationsOption.objects.get_or_create()


class Migration(migrations.Migration):

    dependencies = [("preferences", "0058_auto_20190108_1650")]

    operations = [
        migrations.CreateModel(
            name="CotisationsOption",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "send_voucher_mail",
                    models.BooleanField(
                        default=False,
                        verbose_name="Send voucher by email when the invoice is controlled.",
                    ),
                ),
            ],
            options={"verbose_name": "cotisations options"},
            bases=(re2o.mixins.AclMixin, models.Model),
        ),
        migrations.CreateModel(
            name="DocumentTemplate",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "template",
                    models.FileField(upload_to="templates/", verbose_name="template"),
                ),
                (
                    "name",
                    models.CharField(max_length=125, unique=True, verbose_name="name"),
                ),
            ],
            options={
                "verbose_name": "document template",
                "verbose_name_plural": "document templates",
            },
            bases=(re2o.mixins.RevMixin, re2o.mixins.AclMixin, models.Model),
        ),
        migrations.AddField(
            model_name="assooption",
            name="pres_name",
            field=models.CharField(
                default="",
                help_text="Displayed on subscription vouchers",
                max_length=255,
                verbose_name="President of the association",
            ),
        ),
        migrations.AddField(
            model_name="cotisationsoption",
            name="invoice_template",
            field=models.OneToOneField(
                default=preferences.models.default_invoice,
                on_delete=django.db.models.deletion.PROTECT,
                related_name="invoice_template",
                to="preferences.DocumentTemplate",
                verbose_name="Template for invoices",
            ),
        ),
        migrations.AddField(
            model_name="cotisationsoption",
            name="voucher_template",
            field=models.OneToOneField(
                default=preferences.models.default_voucher,
                on_delete=django.db.models.deletion.PROTECT,
                related_name="voucher_template",
                to="preferences.DocumentTemplate",
                verbose_name="Template for subscription voucher",
            ),
        ),
        migrations.RunPython(create_defaults),
    ]
