# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-07-23 20:36
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import django_dsl.fields
import flexible_reports.models.report
import flexible_reports.models.validators


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('contenttypes', '0002_remove_content_type_name'),
    ]

    operations = [
        migrations.CreateModel(
            name='Column',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('label', models.TextField()),
                ('position', models.PositiveIntegerField(default=0)),
                ('sortable', models.BooleanField(default=True)),
                ('attr_name', models.CharField(help_text="\n        Attribute name on the parent table's model, used to sort and to \n        extract information. ", max_length=200, verbose_name='Attribute name')),
                ('template', models.TextField(default='{{ obj.attribute }}')),
            ],
            options={
                'verbose_name': 'Column',
                'verbose_name_plural': 'Columns',
                'ordering': ('position',),
            },
        ),
        migrations.CreateModel(
            name='Datasource',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('label', models.TextField()),
                ('dsl_query', django_dsl.fields.DjangoDSLField(verbose_name='DSL query')),
                ('base_model', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType', verbose_name='Base model')),
            ],
            options={
                'verbose_name': 'Datasource',
                'verbose_name_plural': 'Datasources',
            },
        ),
        migrations.CreateModel(
            name='Report',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.TextField()),
                ('subtitle', models.TextField(blank=True, null=True)),
                ('slug', models.SlugField()),
                ('template', models.TextField(default=flexible_reports.models.report.get_reports_template, validators=[flexible_reports.models.validators.TemplateValidator])),
            ],
            options={
                'verbose_name': 'Report',
                'verbose_name_plural': 'Reports',
            },
        ),
        migrations.CreateModel(
            name='ReportElement',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.TextField()),
                ('subtitle', models.TextField(blank=True, null=True)),
                ('position', models.PositiveIntegerField(default=0)),
                ('slug', models.CharField(max_length=200)),
                ('datasource', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='flexible_reports.Datasource')),
                ('parent', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='flexible_reports.Report')),
            ],
            options={
                'ordering': ('position',),
            },
        ),
        migrations.CreateModel(
            name='Table',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('label', models.TextField()),
                ('base_model', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')),
            ],
            options={
                'verbose_name': 'Table',
                'verbose_name_plural': 'Tables',
            },
        ),
        migrations.AddField(
            model_name='reportelement',
            name='table',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='flexible_reports.Table'),
        ),
        migrations.AddField(
            model_name='column',
            name='parent',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='flexible_reports.Table'),
        ),
        migrations.AlterUniqueTogether(
            name='reportelement',
            unique_together=set([('parent', 'slug'), ('parent', 'position')]),
        ),
        migrations.AlterUniqueTogether(
            name='column',
            unique_together=set([('parent', 'position')]),
        ),
    ]
