# Generated by Django 4.0.2 on 2022-02-22 01:23

import datetime
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import medialib.models
import rest.models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('account', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='AccountConfig',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(help_text='Name config group', max_length=127)),
            ],
        ),
        migrations.CreateModel(
            name='CuePoint',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('start', models.FloatField()),
                ('end', models.FloatField(blank=True, null=True)),
            ],
        ),
        migrations.CreateModel(
            name='MediaItem',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(help_text='Name of item', max_length=127)),
                ('description', models.TextField(blank=True, help_text='Description of item')),
                ('created', models.DateTimeField(auto_now_add=True, help_text='When item was created')),
                ('kind', models.CharField(choices=[('I', 'Image'), ('V', 'Video'), ('D', 'Audio'), ('L', 'Live Video'), ('A', 'Live Archive'), ('S', 'Video Segment'), ('E', 'External Link'), ('T', 'Text'), ('*', 'Unknown')], help_text='Kind of media', max_length=1)),
                ('state', models.IntegerField(choices=[(0, 'Inactive'), (1, 'Deleted'), (50, 'Archived'), (90, 'Hold'), (100, 'Initial render pending'), (101, 'Render pending'), (102, 'Rendering'), (110, 'Render failed'), (111, 'Validation failed'), (120, 'Render ending'), (200, 'Active')], help_text='Rendering state of item')),
                ('render_error', models.TextField(blank=True, help_text='Any render error messages', null=True)),
                ('group', models.ForeignKey(blank=True, default=None, help_text='Owner of item', null=True, on_delete=django.db.models.deletion.CASCADE, to='account.group')),
            ],
            bases=(models.Model, rest.models.RestModel, rest.models.MetaDataModel),
        ),
        migrations.CreateModel(
            name='MediaItemRendition',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(help_text='Name of rendition (copied from definition)', max_length=127)),
                ('use', models.CharField(blank=True, help_text='The intended use for this media item (copied from definition)', max_length=32, null=True)),
                ('url', models.CharField(help_text='internal url for rendition', max_length=255)),
                ('created', models.DateTimeField(auto_now_add=True, help_text='When item was created')),
                ('width', models.IntegerField(help_text='Width (if available)', null=True)),
                ('height', models.IntegerField(help_text='Height (if available)', null=True)),
                ('bytes', models.IntegerField(help_text='Size of rendition file')),
                ('kind', models.CharField(choices=[('I', 'Image'), ('V', 'Video'), ('D', 'Audio'), ('L', 'Live Stream'), ('N', 'Animated Image'), ('E', 'External Link'), ('T', 'Text'), ('*', 'Unknown')], help_text='Kind of rendition', max_length=1)),
                ('is_original', models.BooleanField(default=False, help_text='Whether is original of kind')),
                ('mediaitem', models.ForeignKey(help_text='Item this rendition is for', on_delete=django.db.models.deletion.CASCADE, related_name='renditions', to='medialib.mediaitem')),
            ],
        ),
        migrations.CreateModel(
            name='RenditionDefinition',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(db_index=True, help_text='Definition name', max_length=127)),
                ('description', models.TextField(blank=True, help_text='Definition description', null=True)),
                ('active', models.BooleanField(default=True, help_text='Should use for new media')),
                ('use', models.CharField(blank=True, help_text='The intended use for this rendition type', max_length=32, null=True)),
                ('depend', models.CharField(blank=True, db_index=True, help_text='Depends on (use name)', max_length=127)),
                ('configSet', models.ManyToManyField(blank=True, help_text='Additional account config set defaults', to='medialib.AccountConfig')),
            ],
            options={
                'ordering': ['preset__stage', 'id'],
            },
        ),
        migrations.CreateModel(
            name='RenditionParameter',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(help_text='Parameter name', max_length=127)),
                ('description', models.TextField(blank=True, help_text='Parameter description', null=True)),
                ('required', models.BooleanField(default=False, help_text='Whether is required')),
                ('kind', models.CharField(choices=[('S', 'String'), ('I', 'Integer'), ('F', 'Float'), ('B', 'Boolean'), ('C', 'Choices')], help_text='Type of value', max_length=1)),
                ('choices', models.TextField(blank=True, help_text='Comma separated list of choices', null=True)),
            ],
        ),
        migrations.CreateModel(
            name='RenditionPreset',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(help_text='Name of preset', max_length=127)),
                ('short_name', models.SlugField(help_text='short name', max_length=32, unique=True)),
                ('description', models.TextField(blank=True, help_text='Preset description', null=True)),
                ('stage', models.IntegerField(help_text='0-100: run when uploaded, >100: run later')),
                ('default_use', models.CharField(blank=True, help_text='The default intended use for this rendition types based on this preset', max_length=32, null=True)),
                ('applicable_kinds', models.CharField(help_text='Applicable rendition kinds', max_length=16)),
                ('module_name', models.SlugField(help_text='module name', max_length=32)),
                ('configurable_parameters', models.ManyToManyField(blank=True, help_text='All parameters that can be set by user', related_name='applicable_renditions', to='medialib.RenditionParameter')),
            ],
        ),
        migrations.CreateModel(
            name='RenditionSet',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(db_index=True, help_text='Set name', max_length=127)),
                ('kind', models.CharField(choices=[('I', 'Image'), ('V', 'Video'), ('D', 'Audio'), ('L', 'Live Video'), ('A', 'Live Archive'), ('S', 'Video Segment'), ('E', 'External Link'), ('T', 'Text'), ('*', 'Unknown')], help_text='Kind of media this rendition set is for', max_length=1)),
                ('default_set', models.BooleanField(default=False, help_text='Whether is global default')),
                ('renditions', models.ManyToManyField(blank=True, help_text='Renditions used', to='medialib.RenditionDefinition')),
            ],
        ),
        migrations.CreateModel(
            name='RenditionSegment',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('segment', models.IntegerField(help_text='Segment number')),
                ('start', models.FloatField(db_index=True, help_text='Start time offset')),
                ('end', models.FloatField(db_index=True, help_text='End time offset')),
                ('duration', models.FloatField(help_text='Segment duration')),
                ('bytes', models.IntegerField(help_text='Segment size')),
                ('url', models.CharField(help_text='internal url for rendition', max_length=255)),
                ('rendition', models.ForeignKey(help_text='Rendition this metadata belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='segments', to='medialib.mediaitemrendition')),
            ],
        ),
        migrations.CreateModel(
            name='RenditionPresetParameterSetting',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('setting', models.CharField(blank=True, help_text='Value', max_length=127, null=True)),
                ('parameter', models.ForeignKey(help_text='Parameter', on_delete=django.db.models.deletion.CASCADE, to='medialib.renditionparameter')),
                ('renditionPreset', models.ForeignKey(help_text='Preset this pair belongs to', on_delete=django.db.models.deletion.CASCADE, to='medialib.renditionpreset')),
            ],
            options={
                'unique_together': {('renditionPreset', 'parameter')},
            },
        ),
        migrations.AddField(
            model_name='renditionpreset',
            name='parameters',
            field=models.ManyToManyField(blank=True, help_text='Default values for parameters', through='medialib.RenditionPresetParameterSetting', to='medialib.RenditionParameter'),
        ),
        migrations.CreateModel(
            name='RenditionDefinitionParameterSetting',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('setting', models.CharField(blank=True, help_text='Value', max_length=127, null=True)),
                ('parameter', models.ForeignKey(help_text='Parameter', on_delete=django.db.models.deletion.CASCADE, to='medialib.renditionparameter')),
                ('renditionDefinition', models.ForeignKey(help_text='Definition this pair belongs to', on_delete=django.db.models.deletion.CASCADE, to='medialib.renditiondefinition')),
            ],
            options={
                'unique_together': {('renditionDefinition', 'parameter')},
            },
        ),
        migrations.AddField(
            model_name='renditiondefinition',
            name='parameters',
            field=models.ManyToManyField(help_text='Configured parameters (override values only)', through='medialib.RenditionDefinitionParameterSetting', to='medialib.RenditionParameter'),
        ),
        migrations.AddField(
            model_name='renditiondefinition',
            name='preset',
            field=models.ForeignKey(help_text='Base preset', on_delete=django.db.models.deletion.CASCADE, related_name='+', to='medialib.renditionpreset'),
        ),
        migrations.CreateModel(
            name='RenderInstance',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('instance_id', models.CharField(db_index=True, help_text='Rendering engine ID', max_length=16)),
                ('state', models.CharField(choices=[('S', 'Starting'), ('I', 'Idle'), ('R', 'Rendering'), ('0', 'Stopped')], db_index=True, help_text='Current state of engine', max_length=1)),
                ('started', models.DateTimeField(auto_now_add=True, help_text='When rendering was started')),
                ('last_checkin', models.DateTimeField(default=datetime.datetime.now, help_text='time instance last checked in')),
                ('shutdown', models.DateTimeField(blank=True, help_text='Time of instance shutdown', null=True)),
                ('priority', models.IntegerField(blank=True, default=medialib.models._next_priority, help_text='Render instance priority', null=True)),
                ('message', models.TextField(blank=True, help_text='Render message', null=True)),
                ('rendering', models.ForeignKey(blank=True, help_text='Media item currently being rendered', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='render_instance', to='medialib.mediaitem')),
            ],
        ),
        migrations.CreateModel(
            name='MediaMeta',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('key', models.CharField(db_index=True, help_text='Key', max_length=127)),
                ('value', models.TextField(blank=True, help_text='Value', null=True)),
                ('rendition', models.ForeignKey(help_text='Rendition this metadata belongs to', on_delete=django.db.models.deletion.CASCADE, to='medialib.mediaitemrendition')),
            ],
        ),
        migrations.CreateModel(
            name='MediaLibrary',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(help_text='name of media library', max_length=127)),
                ('description', models.TextField(blank=True, help_text='description of media library', null=True)),
                ('allowed_kinds', models.CharField(blank=True, help_text='allowed object kinds (null=ALL)', max_length=127, null=True)),
                ('group', models.ForeignKey(blank=True, default=None, help_text='group owner of library', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='libraries', to='account.group')),
                ('owner', models.ForeignKey(blank=True, default=None, help_text='owner of library', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='libraries', to=settings.AUTH_USER_MODEL)),
                ('rendition_sets', models.ManyToManyField(blank=True, help_text='list of RenditionSets used in this library', to='medialib.RenditionSet')),
            ],
            options={
                'permissions': (('can_manage', 'Can manage medialib directly'),),
            },
        ),
        migrations.AddField(
            model_name='mediaitemrendition',
            name='rendition_definition',
            field=models.ForeignKey(help_text='The rendition type that generated this rendition', null=True, on_delete=django.db.models.deletion.CASCADE, to='medialib.renditiondefinition'),
        ),
        migrations.CreateModel(
            name='MediaItemRef',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('component', models.CharField(blank=True, db_index=True, default=None, max_length=200, null=True)),
                ('component_id', models.IntegerField(db_index=True)),
                ('media', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='references', to='medialib.mediaitem')),
            ],
            bases=(models.Model, rest.models.RestModel),
        ),
        migrations.CreateModel(
            name='MediaItemMetaData',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('category', models.CharField(blank=True, db_index=True, default=None, max_length=32, null=True)),
                ('key', models.CharField(db_index=True, max_length=80)),
                ('value_format', models.CharField(max_length=16)),
                ('value', models.TextField()),
                ('int_value', models.IntegerField(blank=True, default=None, null=True)),
                ('float_value', models.IntegerField(blank=True, default=None, null=True)),
                ('parent', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='properties', to='medialib.mediaitem')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.AddField(
            model_name='mediaitem',
            name='library',
            field=models.ForeignKey(blank=True, default=None, help_text='Library this item belongs to', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='items', to='medialib.medialibrary'),
        ),
        migrations.AddField(
            model_name='mediaitem',
            name='owner',
            field=models.ForeignKey(blank=True, default=None, help_text='Owner of item', null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
        ),
        migrations.CreateModel(
            name='CuePointMeta',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('key', models.CharField(db_index=True, help_text='Key', max_length=127)),
                ('value', models.TextField(blank=True, help_text='Value', null=True)),
                ('cue', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='medialib.cuepoint')),
            ],
        ),
        migrations.AddField(
            model_name='cuepoint',
            name='item',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='medialib.mediaitem'),
        ),
        migrations.AddField(
            model_name='cuepoint',
            name='subitem',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='cueparent', to='medialib.mediaitem'),
        ),
        migrations.CreateModel(
            name='AccountConfigParameterSetting',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('setting', models.CharField(blank=True, help_text='Value', max_length=127, null=True)),
                ('accountConfig', models.ForeignKey(help_text='Config this pair belongs to', on_delete=django.db.models.deletion.CASCADE, to='medialib.accountconfig')),
                ('parameter', models.ForeignKey(help_text='Parameter', on_delete=django.db.models.deletion.CASCADE, to='medialib.renditionparameter')),
            ],
            options={
                'unique_together': {('accountConfig', 'parameter')},
            },
        ),
        migrations.AddField(
            model_name='accountconfig',
            name='applicable_preset',
            field=models.ForeignKey(blank=True, help_text='Applicable preset (info only)', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='+', to='medialib.renditionpreset'),
        ),
        migrations.AddField(
            model_name='accountconfig',
            name='owner',
            field=models.ForeignKey(help_text='owner of config', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='accountconfig',
            name='parameters',
            field=models.ManyToManyField(blank=True, help_text='Values for parameters', through='medialib.AccountConfigParameterSetting', to='medialib.RenditionParameter'),
        ),
        migrations.CreateModel(
            name='MediaItemParameterSetting',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('setting', models.CharField(blank=True, help_text='Value', max_length=127, null=True)),
                ('item', models.ForeignKey(help_text='Media Item this pair belongs to', on_delete=django.db.models.deletion.CASCADE, to='medialib.mediaitem')),
                ('parameter', models.ForeignKey(help_text='Parameter', on_delete=django.db.models.deletion.CASCADE, to='medialib.renditionparameter')),
            ],
            options={
                'unique_together': {('item', 'parameter')},
            },
        ),
    ]
