# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2020-09-29 17:18
from __future__ import unicode_literals

from django.conf import settings
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('dataentry', '0154_vdf_v2_continued'),
    ]

    operations = [
        migrations.CreateModel(
            name='Audit',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('start_date', models.DateField()),
                ('end_date', models.DateField()),
                ('percent_to_sample', models.FloatField(verbose_name=100)),
                ('notes', models.TextField(blank=True)),
                ('template', django.contrib.postgres.fields.jsonb.JSONField(null=True)),
                ('author', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
                ('country', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dataentry.Country')),
                ('form', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dataentry.Form')),
            ],
        ),
        migrations.CreateModel(
            name='AuditSample',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('form_id', models.PositiveIntegerField()),
                ('form_number', models.CharField(max_length=126)),
                ('detail_notes', models.TextField(blank=True)),
                ('high_level_notes', models.TextField(blank=True)),
                ('completion_date', models.DateField(null=True)),
                ('results', django.contrib.postgres.fields.jsonb.JSONField(null=True)),
                ('corrected', models.CharField(max_length=126)),
                ('audit', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dataentry.Audit')),
                ('auditor', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.RunSQL(
            "insert into dataentry_permission (permission_group, action, min_level)  values ('AUDIT','VIEW','COUNTRY')"
            ),
        migrations.RunSQL(
            "insert into dataentry_permission (permission_group, action, min_level)  values ('AUDIT','EDIT','GLOBAL')"
            ),
        migrations.RunSQL(
            "insert into dataentry_permission (permission_group, action, min_level)  values ('AUDIT','ADD','GLOBAL')"
            ),
        migrations.RunSQL(
            "insert into dataentry_permission (permission_group, action, min_level)  values ('AUDIT','SUBMIT_SAMPLE','COUNTRY')"
            ),
    ]
