# -*- coding: utf-8 -*-
# Generated by Django 1.11.7 on 2017-12-18 14:08
from __future__ import unicode_literals

import c3nav.mapdata.models.access
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):

    dependencies = [
        ('mapdata', '0059_multiple_accesspermissions'),
    ]

    operations = [
        migrations.RemoveField(
            model_name='accesspermissiontoken',
            name='author',
        ),
        migrations.RemoveField(
            model_name='accesspermission',
            name='token',
        ),
        migrations.DeleteModel(
            name='AccessPermissionToken',
        ),
        migrations.CreateModel(
            name='AccessPermissionToken',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('token', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ('valid_until',
                 models.DateTimeField(db_index=True, default=c3nav.mapdata.models.access.default_valid_until,
                                      verbose_name='valid until')),
                ('unlimited', models.BooleanField(db_index=True, default=False, verbose_name='unlimited')),
                ('redeemed', models.BooleanField(db_index=True, default=False, verbose_name='redeemed')),
                ('can_grant', models.BooleanField(db_index=True, default=False, verbose_name='can grant')),
                ('data', models.BinaryField()),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT,
                                             related_name='created_accesspermission_tokens',
                                             to=settings.AUTH_USER_MODEL, verbose_name='author')),
            ],
        ),
        migrations.AddField(
            model_name='accesspermission',
            name='token',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE,
                                    related_name='accesspermissions', to='mapdata.AccessPermissionToken',
                                    verbose_name='Access permission token'),
        ),
    ]
