# Generated by Django 2.2.1 on 2019-05-18 16:53

from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import jsonfield.fields
import spkcspider.apps.spider.models.protections
import spkcspider.apps.spider.validators


class Migration(migrations.Migration):

    replaces = [('spider_base', '0002_20190127_squashed'), ('spider_base', '0003_auto_20190128_1339'), ('spider_base', '0004_auto_20190128_1349'), ('spider_base', '0005_auto_20190128_2230'), ('spider_base', '0006_auto_20190128_2251'), ('spider_base', '0007_usercomponent_allow_domain_mode'), ('spider_base', '0008_auto_20190225_2034'), ('spider_base', '0009_auto_20190317_1405'), ('spider_base', '0010_assignedcontent_attached_to_primary_anchor'), ('spider_base', '0011_auto_20190331_1222'), ('spider_base', '0012_auto_20190404_2116'), ('spider_base', '0013_auto_20190407_1313'), ('spider_base', '0014_auto_20190407_1416'), ('spider_base', '0015_auto_20190414_1743'), ('spider_base', '0016_auto_20190414_1743'), ('spider_base', '0017_auto_20190504_1640'), ('spider_base', '0018_auto_20190505_1336'), ('spider_base', '0019_contentvariant_valid_feature_for'), ('spider_base', '0020_auto_20190509_1520'), ('spider_base', '0021_auto_20190511_1046'), ('spider_base', '0022_auto_20190512_1630'), ('spider_base', '0023_auto_20190513_1506'), ('spider_base', '0024_auto_20190514_1853')]

    dependencies = [
        ('spider_base', '0001_initial'),
        ('contenttypes', '0002_remove_content_type_name'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.AddField(
            model_name='assignedcontent',
            name='strength',
            field=models.PositiveSmallIntegerField(default=0, editable=False, validators=[django.core.validators.MaxValueValidator(10)]),
        ),
        migrations.AddField(
            model_name='assignedcontent',
            name='strength_link',
            field=models.PositiveSmallIntegerField(default=0, editable=False, validators=[django.core.validators.MaxValueValidator(11)]),
        ),
        migrations.AddField(
            model_name='contentvariant',
            name='strength',
            field=models.PositiveSmallIntegerField(default=0, validators=[django.core.validators.MaxValueValidator(10)]),
        ),
        migrations.AddField(
            model_name='usercomponent',
            name='strength',
            field=models.PositiveSmallIntegerField(default=0, editable=False, validators=[django.core.validators.MaxValueValidator(10)]),
        ),
        migrations.AlterField(
            model_name='contentvariant',
            name='ctype',
            field=models.CharField(default='', max_length=10),
        ),
        migrations.AlterField(
            model_name='contentvariant',
            name='name',
            field=models.SlugField(unique=True),
        ),
        migrations.AlterField(
            model_name='assignedprotection',
            name='protection',
            field=models.ForeignKey(limit_choices_to=spkcspider.apps.spider.models.protections.get_limit_choices_assigned_protection, on_delete=django.db.models.deletion.CASCADE, related_name='assigned', to='spider_base.Protection'),
        ),
        migrations.AlterField(
            model_name='usercomponent',
            name='deletion_requested',
            field=models.DateTimeField(blank=True, default=None, null=True),
        ),
        migrations.AlterField(
            model_name='usercomponent',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AlterModelOptions(
            name='usercomponent',
            options={'permissions': [('can_feature', 'Can feature User Components')]},
        ),
        migrations.AddField(
            model_name='usercomponent',
            name='featured',
            field=models.BooleanField(default=False, help_text='Appears as featured on "home" page'),
        ),
        migrations.AlterField(
            model_name='usercomponent',
            name='name',
            field=models.SlugField(allow_unicode=True, help_text='\nName of the component.<br/>\nNote: there are special named components\nwith different protection types and scopes.<br/>\nMost prominent: "index" for authentication\n'),
        ),
        migrations.AddField(
            model_name='usercomponent',
            name='description',
            field=models.TextField(blank=True, default='', help_text='Description of user component.'),
        ),
        migrations.AddField(
            model_name='assignedcontent',
            name='references',
            field=models.ManyToManyField(editable=False, related_name='referenced_by', to='spider_base.AssignedContent'),
        ),
        migrations.AddField(
            model_name='authtoken',
            name='extra',
            field=jsonfield.fields.JSONField(blank=True, default=dict),
        ),

        migrations.CreateModel(
            name='TravelProtection',
            fields=[
                ('id', models.BigAutoField(editable=False, primary_key=True, serialize=False)),
                ('active', models.BooleanField(blank=True, default=False)),
                ('approved', models.BooleanField(blank=True, default=False)),
                ('start', models.DateTimeField(blank=True, null=True)),
                ('stop', models.DateTimeField(blank=True, null=True)),
                ('login_protection', models.CharField(choices=[('a', 'Hide'), ('b', 'Hide if triggered'), ('c', 'Disable login'), ('C', 'Disable login if triggered'), ('d', 'Wipe'), ('e', 'Wipe User')], default='a', max_length=1)),
                ('protect_contents', models.ManyToManyField(blank=True, related_name='travel_protected', to='spider_base.AssignedContent')),
                ('protect_components', models.ManyToManyField(blank=True, limit_choices_to={'strength__lt': 10}, related_name='travel_protected', to='spider_base.UserComponent')),
            ],
            options={
                'abstract': False,
                'default_permissions': (),
                'permissions': [('approve_travelprotection', 'Can approve dangerous TravelProtections')]
            },
        ),
        migrations.AlterField(
            model_name='usercomponent',
            name='name',
            field=models.SlugField(allow_unicode=True, help_text='Name of the component.<br/>Note: there are special named components with different protection types and scopes.<br/>Most prominent: "index" for authentication'),
        ),
        migrations.AddField(
            model_name='usercomponent',
            name='features',
            field=models.ManyToManyField(blank=True, limit_choices_to=models.Q(ctype__contains='a'), related_name='supports', to='spider_base.ContentVariant'),
        ),
        migrations.AlterField(
            model_name='assignedcontent',
            name='ctype',
            field=models.ForeignKey(editable=False, limit_choices_to=models.Q(_negated=True, ctype__contains='a'), null=True, on_delete=django.db.models.deletion.SET_NULL, to='spider_base.ContentVariant'),
        ),
        migrations.AlterUniqueTogether(
            name='authtoken',
            unique_together=set(),
        ),
        migrations.AlterField(
            model_name='assignedcontent',
            name='ctype',
            field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.SET_NULL, to='spider_base.ContentVariant'),
        ),
        migrations.RenameField(
            model_name='userinfo',
            old_name='used_space',
            new_name='used_space_local',
        ),
        migrations.AddField(
            model_name='userinfo',
            name='used_space_remote',
            field=models.BigIntegerField(default=0, editable=False),
        ),
        migrations.AddField(
            model_name='assignedcontent',
            name='priority',
            field=models.SmallIntegerField(blank=True, default=0),
        ),
        migrations.AddField(
            model_name='linkcontent',
            name='push',
            field=models.BooleanField(blank=True, default=False, help_text='Improve ranking of this Link.'),
        ),
        migrations.AddField(
            model_name='authtoken',
            name='referrer',
            field=models.URLField(blank=True, max_length=400, null=True),
        ),
        migrations.AddField(
            model_name='authtoken',
            name='persist',
            field=models.BigIntegerField(blank=True, db_index=True, default=-1),
        ),
        migrations.AddField(
            model_name='usercomponent',
            name='can_auth',
            field=models.BooleanField(default=False, editable=False),
        ),
        migrations.AddField(
            model_name='usercomponent',
            name='primary_anchor',
            field=models.ForeignKey(blank=True, help_text='Select main identyifing anchor. Also used for attaching persisting tokens (elsewise they are attached to component)', limit_choices_to={'info__contains': '\nanchor\n'}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='primary_anchor_for', to='spider_base.AssignedContent'),
        ),
        migrations.AlterField(
            model_name='linkcontent',
            name='content',
            field=models.ForeignKey(limit_choices_to={'strength_link__lte': 10}, on_delete=django.db.models.deletion.CASCADE, related_name='+', to='spider_base.AssignedContent'),
        ),
        migrations.AlterField(
            model_name='usercomponent',
            name='public',
            field=models.BooleanField(default=False, help_text='Is public? Is listed and searchable?<br/>Note: This field is maybe not deactivatable because of assigned content'),
        ),
        migrations.AddField(
            model_name='assignedcontent',
            name='attached_to_token',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='spider_base.AuthToken'),
        ),
        migrations.AddField(
            model_name='usercomponent',
            name='allow_domain_mode',
            field=models.BooleanField(default=False),
        ),
        migrations.CreateModel(
            name='ReferrerObject',
            fields=[
                ('id', models.BigAutoField(editable=False, primary_key=True, serialize=False)),
                ('url', models.URLField(db_index=True, editable=False, max_length=600, unique=True)),
            ],
        ),
        migrations.AlterField(
            model_name='authtoken',
            name='referrer',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='tokens', to='spider_base.ReferrerObject'),
        ),
        migrations.AddField(
            model_name='assignedcontent',
            name='allow_domain_mode',
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name='assignedcontent',
            name='attached_to_content',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='attached_contents', to='spider_base.AssignedContent'),
        ),
        migrations.AddField(
            model_name='assignedcontent',
            name='features',
            field=models.ManyToManyField(blank=True, limit_choices_to=models.Q(ctype__contains='g'), related_name='feature_for_contents', to='spider_base.ContentVariant'),
        ),
        migrations.AlterField(
            model_name='usercomponent',
            name='features',
            field=models.ManyToManyField(blank=True, limit_choices_to=models.Q(ctype__contains='f'), related_name='feature_for_components', to='spider_base.ContentVariant'),
        ),
        migrations.AddField(
            model_name='assignedcontent',
            name='attached_to_primary_anchor',
            field=models.BooleanField(default=False, editable=False, help_text='Content references primary anchor'),
        ),
        migrations.AddField(
            model_name='usercomponent',
            name='default_content_features',
            field=models.ManyToManyField(blank=True, help_text='Select features used by default for contents in this component', limit_choices_to=models.Q(ctype__contains='g'), related_name='default_feature_for_contents', to='spider_base.ContentVariant'),
        ),
        migrations.AlterField(
            model_name='usercomponent',
            name='primary_anchor',
            field=models.ForeignKey(blank=True, help_text='Select main identifying anchor. Also used for attaching persisting tokens (elsewise they are attached to component)', limit_choices_to={'info__contains': '\nanchor\n'}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='primary_anchor_for', to='spider_base.AssignedContent'),
        ),
        migrations.AddField(
            model_name='assignedcontent',
            name='description',
            field=models.TextField(blank=True, default=''),
        ),
        migrations.AddField(
            model_name='assignedcontent',
            name='name',
            field=models.CharField(blank=True, default='', max_length=255, validators=[spkcspider.apps.spider.validators.content_name_validator]),
        ),
        migrations.AlterField(
            model_name='usercomponent',
            name='name',
            field=models.CharField(db_index=True, help_text='Name of the component.<br/>Note: there are special named components with different protection types and scopes.<br/>Most prominent: "index" for authentication', max_length=255, validators=[django.core.validators.RegexValidator('^(\\w[\\w ]*\\w|\\w?)$')]),
        ),
        migrations.AlterField(
            model_name='usercomponent',
            name='primary_anchor',
            field=models.ForeignKey(blank=True, help_text='Select main identifying anchor. Also used for attaching persisting tokens (elsewise they are attached to component)', limit_choices_to={'info__contains': '\x1eanchor\x1e'}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='primary_anchor_for', to='spider_base.AssignedContent'),
        ),
        migrations.AlterUniqueTogether(
            name='assignedcontent',
            unique_together={('content_type', 'object_id')},
        ),
        migrations.AddConstraint(
            model_name='assignedcontent',
            constraint=models.UniqueConstraint(fields=('usercomponent', 'info'), name='unique_info'),
        ),
        migrations.AlterField(
            model_name='assignedcontent',
            name='token',
            field=models.CharField(blank=True, db_index=True, max_length=138, null=True, unique=True, validators=[django.core.validators.RegexValidator('\\A[-a-zA-Z0-9_]+\\Z', 'Enter a valid token.', 'invalid_token')]),
        ),
        migrations.AlterField(
            model_name='authtoken',
            name='token',
            field=models.CharField(db_index=True, max_length=138, unique=True, validators=[django.core.validators.RegexValidator('\\A[-a-zA-Z0-9_]+\\Z', 'Enter a valid token.', 'invalid_token')]),
        ),
        migrations.AlterField(
            model_name='usercomponent',
            name='token',
            field=models.CharField(blank=True, db_index=True, max_length=138, null=True, unique=True, validators=[django.core.validators.RegexValidator('\\A[-a-zA-Z0-9_]+\\Z', 'Enter a valid token.', 'invalid_token')]),
        ),
        migrations.AddField(
            model_name='contentvariant',
            name='valid_feature_for',
            field=models.ManyToManyField(blank=True, related_name='valid_features', to='spider_base.ContentVariant'),
        ),
    ]
