class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='Interaction',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('slug', models.SlugField(blank=True, editable=False)),
            ],
        ),
        migrations.CreateModel(
            name='AssetInteraction',
            fields=[
                ('interaction_ptr',
                 models.OneToOneField(
                     auto_created=True,
                     on_delete=django.db.models.deletion.CASCADE,
                     parent_link=True,
                     primary_key=True,
                     serialize=False,
                     to='insights.Interaction')),
                ('type',
                 models.CharField(choices=[('WDC', 'word clicks'),
                                           ('VDC', 'video clicks'),
                                           ('ADC', 'audio clicks')],
                                  max_length=3)),
                ('value', models.IntegerField(default=0)),
                ('asset',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   related_name='clicks',
                                   to='book.Asset')),
            ],
            bases=('insights.interaction', ),
        ),
        migrations.CreateModel(
            name='TimeInteraction',
            fields=[
                ('interaction_ptr',
                 models.OneToOneField(
                     auto_created=True,
                     on_delete=django.db.models.deletion.CASCADE,
                     parent_link=True,
                     primary_key=True,
                     serialize=False,
                     to='insights.Interaction')),
                ('page_type',
                 models.CharField(choices=[('SPG', 'story page'),
                                           ('GPG', 'game page')],
                                  max_length=3)),
                ('start', models.DateTimeField()),
                ('duration', models.DurationField(blank=True, null=True)),
                ('end', models.DateTimeField()),
                ('page',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   related_name='dwell_times',
                                   to='book.BookPage')),
            ],
            bases=('insights.interaction', ),
        ),
        migrations.AddField(
            model_name='interaction',
            name='user',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name='interactions',
                to=settings.AUTH_USER_MODEL),
        ),
    ]
예제 #2
0
class Migration(migrations.Migration):

    replaces = []

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('cms', '0022_auto_20180620_1551'),
    ]

    operations = [
        migrations.CreateModel(
            name='ListaProyectosPlugin',
            fields=[
                ('cmsplugin_ptr',
                 models.OneToOneField(
                     auto_created=True,
                     on_delete=django.db.models.deletion.CASCADE,
                     parent_link=True,
                     primary_key=True,
                     related_name='seg_proyectos_listaproyectosplugin',
                     serialize=False,
                     to='cms.CMSPlugin')),
                ('tam_pagina', models.IntegerField(default=10)),
            ],
            options={
                'abstract': False,
            },
            bases=('cms.cmsplugin', ),
        ),
        migrations.CreateModel(
            name='Proyecto',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('nombre', models.CharField(max_length=200)),
                ('descripcion', models.CharField(max_length=1000)),
                ('fecha_inicio',
                 models.DateField(default=django.utils.timezone.now)),
                ('fecha_fin',
                 models.DateField(default=django.utils.timezone.now)),
                ('activo', models.BooleanField(default=True)),
            ],
        ),
        migrations.CreateModel(
            name='ResumenProyectosPlugin',
            fields=[
                ('cmsplugin_ptr',
                 models.OneToOneField(
                     auto_created=True,
                     on_delete=django.db.models.deletion.CASCADE,
                     parent_link=True,
                     primary_key=True,
                     related_name='seg_proyectos_resumenproyectosplugin',
                     serialize=False,
                     to='cms.CMSPlugin')),
                ('Todos Activos', models.BooleanField(null=True)),
            ],
            options={
                'abstract': False,
            },
            bases=('cms.cmsplugin', ),
        ),
        migrations.CreateModel(
            name='ResumenProyectoPlugin',
            fields=[
                ('cmsplugin_ptr',
                 models.OneToOneField(
                     auto_created=True,
                     on_delete=django.db.models.deletion.CASCADE,
                     parent_link=True,
                     primary_key=True,
                     related_name='seg_proyectos_resumenproyectoplugin',
                     serialize=False,
                     to='cms.CMSPlugin')),
                ('proyecto',
                 models.ForeignKey(
                     null=True,
                     on_delete=django.db.models.deletion.SET_NULL,
                     to='seg_proyectos.Proyecto')),
            ],
            options={
                'abstract': False,
            },
            bases=('cms.cmsplugin', ),
        ),
        migrations.CreateModel(
            name='EntradaDeHorasDetallePlugin',
            fields=[
                ('cmsplugin_ptr',
                 models.OneToOneField(
                     auto_created=True,
                     on_delete=django.db.models.deletion.CASCADE,
                     parent_link=True,
                     primary_key=True,
                     related_name='seg_proyectos_entradadehorasdetalleplugin',
                     serialize=False,
                     to='cms.CMSPlugin')),
                ('mostrar_inactivos', models.BooleanField(default=False)),
            ],
            options={
                'abstract': False,
            },
            bases=('cms.cmsplugin', ),
        ),
        migrations.CreateModel(
            name='EntradaDeHorasPlugin',
            fields=[
                ('cmsplugin_ptr',
                 models.OneToOneField(
                     auto_created=True,
                     on_delete=django.db.models.deletion.CASCADE,
                     parent_link=True,
                     primary_key=True,
                     related_name='seg_proyectos_entradadehorasplugin',
                     serialize=False,
                     to='cms.CMSPlugin')),
                ('mostrar_inactivos', models.BooleanField(default=False)),
            ],
            options={
                'abstract': False,
            },
            bases=('cms.cmsplugin', ),
        ),
        migrations.CreateModel(
            name='EntradaHoras',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('valor',
                 models.DecimalField(decimal_places=1,
                                     default=1.0,
                                     max_digits=3)),
                ('fecha', models.DateField()),
                ('proyecto',
                 models.ForeignKey(
                     null=True,
                     on_delete=django.db.models.deletion.SET_NULL,
                     to='seg_proyectos.Proyecto')),
                ('usuario',
                 models.ForeignKey(blank=True,
                                   on_delete=django.db.models.deletion.CASCADE,
                                   to=settings.AUTH_USER_MODEL,
                                   verbose_name='user')),
            ],
        ),
        migrations.CreateModel(
            name='EntradaHorasDetalle',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('entrada', models.DateTimeField()),
                ('salida', models.DateTimeField()),
                ('descanso', models.DurationField(null=True)),
                ('horas',
                 models.ForeignKey(
                     null=True,
                     on_delete=django.db.models.deletion.SET_NULL,
                     to='seg_proyectos.EntradaHoras')),
            ],
        ),
    ]
class Migration(migrations.Migration):

    dependencies = [
        ('mptests', '0003_clientip'),
        ('connectivity', '0002_auto_20180116_1504'),
    ]

    operations = [
        migrations.CreateModel(
            name='ConnectivityConfig',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('port', models.PositiveIntegerField()),
                ('url', models.CharField(max_length=200)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='ConnectivityResult',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('success', models.BooleanField()),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='ConnectivityTest',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('order', models.PositiveIntegerField()),
                ('start_time', models.DateTimeField()),
                ('wait_time', models.DurationField()),
                ('duration', models.DurationField()),
                ('name', models.CharField(max_length=20)),
                ('config', models.CharField(max_length=20)),
                ('benchmark',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='mptests.Benchmark')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.AddField(
            model_name='connectivityresult',
            name='test',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to='connectivity.ConnectivityTest'),
        ),
        migrations.AddField(
            model_name='connectivityconfig',
            name='test',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to='connectivity.ConnectivityTest'),
        ),
    ]
class Migration(migrations.Migration):

    dependencies = [
        ('newops', '0003_device_iam_mechanism_devicespecification_dps_property_iot_hub_vendor'),
    ]

    operations = [
        migrations.CreateModel(
            name='Application',
            fields=[
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('app_name', models.CharField(blank=True, max_length=100, null=True)),
                ('app_type', models.CharField(choices=[('Source', 'Source'), ('End', 'End')], default=None, max_length=100, null=True)),
                ('app_function', models.CharField(blank=True, max_length=100, null=True)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='CA',
            fields=[
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('CAtype', models.CharField(choices=[('True', 'Self'), ('False', 'CA')], default=None, max_length=100)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Customer',
            fields=[
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('company_name', models.CharField(blank=True, max_length=100, null=True)),
                ('address', models.CharField(blank=True, max_length=100, null=True)),
                ('city', models.CharField(blank=True, max_length=100, null=True)),
                ('country', models.CharField(choices=[('IN', 'India'), ('US', 'USA'), ('CA', 'CANADA'), ('BE', 'Belguim'), ('CZ', 'Czechia'), ('DK', 'Denmark'), ('DE', 'Germany'), ('EE', 'Estonia'), ('IE', 'Ireland'), ('EL', 'Greece'), ('ES', 'Spain'), ('FR', 'France'), ('HR', 'Crotia'), ('IT', 'Italy'), ('CY', 'Cyprus'), ('LV', 'Latvia'), ('LT', 'Lithuania'), ('LU', 'Luxembourg'), ('HU', 'Hungary'), ('MT', 'Malta'), ('NL', 'Netherlands'), ('AT', 'Austria'), ('PL', 'Poland'), ('PT', 'Portugal'), ('RO', 'Romania'), ('SL', 'Slovenia'), ('SK', 'Slovakia'), ('FI', 'Finland'), ('SW', 'Sweden'), ('TH', 'Thailand')], default=None, max_length=100, null=True)),
                ('zip_code', models.CharField(max_length=6, validators=[django.core.validators.RegexValidator('^\\d{1,6}$')])),
                ('primary_contact_person', models.CharField(blank=True, max_length=10, null=True, validators=[django.core.validators.RegexValidator('^\\d{1,10}$')])),
                ('designation', models.CharField(blank=True, max_length=100, null=True)),
                ('primary_email', models.EmailField(blank=True, max_length=100, null=True)),
                ('secondary_contact_person', models.CharField(blank=True, max_length=10, null=True, validators=[django.core.validators.RegexValidator('^\\d{1,10}$')])),
                ('s_designation', models.CharField(blank=True, max_length=100, null=True)),
                ('secondary_email', models.EmailField(blank=True, max_length=100, null=True)),
                ('website', models.URLField(blank=True, max_length=100, null=True)),
                ('gst', models.CharField(blank=True, max_length=100, null=True)),
                ('vat', models.CharField(blank=True, max_length=100, null=True)),
                ('installation_mode', models.CharField(choices=[('Edge', 'Edge'), ('Cloud', 'Cloud'), ('Hybrid', 'Hybrid'), ('Other', 'Other')], default=None, max_length=100, null=True)),
                ('no_of_site', models.CharField(choices=[('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6'), ('7', '7'), ('8', '8'), ('9', '9'), ('10', '10')], default=None, max_length=100, null=True)),
                ('site1', models.CharField(blank=True, max_length=100, null=True)),
                ('address_site1', models.CharField(blank=True, max_length=100, null=True)),
                ('city_site1', models.CharField(blank=True, max_length=100, null=True)),
                ('country_site1', models.CharField(choices=[('IN', 'India'), ('US', 'USA'), ('CA', 'CANADA'), ('BE', 'Belguim'), ('CZ', 'Czechia'), ('DK', 'Denmark'), ('DE', 'Germany'), ('EE', 'Estonia'), ('IE', 'Ireland'), ('EL', 'Greece'), ('ES', 'Spain'), ('FR', 'France'), ('HR', 'Crotia'), ('IT', 'Italy'), ('CY', 'Cyprus'), ('LV', 'Latvia'), ('LT', 'Lithuania'), ('LU', 'Luxembourg'), ('HU', 'Hungary'), ('MT', 'Malta'), ('NL', 'Netherlands'), ('AT', 'Austria'), ('PL', 'Poland'), ('PT', 'Portugal'), ('RO', 'Romania'), ('SL', 'Slovenia'), ('SK', 'Slovakia'), ('FI', 'Finland'), ('SW', 'Sweden'), ('TH', 'Thailand')], default=None, max_length=100, null=True)),
                ('site2', models.CharField(blank=True, max_length=100, null=True)),
                ('address_site2', models.CharField(blank=True, max_length=100, null=True)),
                ('city_site2', models.CharField(blank=True, max_length=100, null=True)),
                ('country_site2', models.CharField(choices=[('IN', 'India'), ('US', 'USA'), ('CA', 'CANADA'), ('BE', 'Belguim'), ('CZ', 'Czechia'), ('DK', 'Denmark'), ('DE', 'Germany'), ('EE', 'Estonia'), ('IE', 'Ireland'), ('EL', 'Greece'), ('ES', 'Spain'), ('FR', 'France'), ('HR', 'Crotia'), ('IT', 'Italy'), ('CY', 'Cyprus'), ('LV', 'Latvia'), ('LT', 'Lithuania'), ('LU', 'Luxembourg'), ('HU', 'Hungary'), ('MT', 'Malta'), ('NL', 'Netherlands'), ('AT', 'Austria'), ('PL', 'Poland'), ('PT', 'Portugal'), ('RO', 'Romania'), ('SL', 'Slovenia'), ('SK', 'Slovakia'), ('FI', 'Finland'), ('SW', 'Sweden'), ('TH', 'Thailand')], default=None, max_length=100, null=True)),
                ('site3', models.CharField(blank=True, max_length=100, null=True)),
                ('address_site3', models.CharField(blank=True, max_length=100, null=True)),
                ('city_site3', models.CharField(blank=True, max_length=100, null=True)),
                ('country_site3', models.CharField(choices=[('IN', 'India'), ('US', 'USA'), ('CA', 'CANADA'), ('BE', 'Belguim'), ('CZ', 'Czechia'), ('DK', 'Denmark'), ('DE', 'Germany'), ('EE', 'Estonia'), ('IE', 'Ireland'), ('EL', 'Greece'), ('ES', 'Spain'), ('FR', 'France'), ('HR', 'Crotia'), ('IT', 'Italy'), ('CY', 'Cyprus'), ('LV', 'Latvia'), ('LT', 'Lithuania'), ('LU', 'Luxembourg'), ('HU', 'Hungary'), ('MT', 'Malta'), ('NL', 'Netherlands'), ('AT', 'Austria'), ('PL', 'Poland'), ('PT', 'Portugal'), ('RO', 'Romania'), ('SL', 'Slovenia'), ('SK', 'Slovakia'), ('FI', 'Finland'), ('SW', 'Sweden'), ('TH', 'Thailand')], default=None, max_length=100, null=True)),
                ('application', models.ForeignKey(default='', on_delete=django.db.models.deletion.CASCADE, to='newops.Application')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Permissions',
            fields=[
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('permission_name', models.CharField(blank=True, max_length=100, null=True, unique=True)),
                ('add_permission', models.CharField(choices=[('True', 'True'), ('False', 'False')], default=None, max_length=100, null=True)),
                ('edit_permission', models.CharField(choices=[('True', 'True'), ('False', 'False')], default=None, max_length=100, null=True)),
                ('modify_permission', models.CharField(choices=[('True', 'True'), ('False', 'False')], default=None, max_length=100, null=True)),
                ('view_permission', models.CharField(choices=[('True', 'True'), ('False', 'False')], default=None, max_length=100, null=True)),
                ('log_permission', models.CharField(choices=[('True', 'True'), ('False', 'False')], default=None, max_length=100, null=True)),
                ('delete_permission', models.CharField(choices=[('True', 'True'), ('False', 'False')], default=None, max_length=100, null=True)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='UserGroup',
            fields=[
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('usergroup', models.CharField(blank=True, max_length=100, null=True)),
                ('superadmin', models.CharField(blank=True, max_length=100, null=True)),
                ('admin', models.CharField(blank=True, max_length=100, null=True)),
                ('localadmin', models.CharField(blank=True, max_length=100, null=True)),
                ('manager', models.CharField(blank=True, max_length=100, null=True)),
                ('supervisor', models.CharField(blank=True, max_length=100, null=True)),
                ('operator', models.CharField(blank=True, max_length=100, null=True)),
                ('support', models.CharField(blank=True, max_length=100, null=True)),
                ('staff', models.CharField(blank=True, max_length=100, null=True)),
                ('other1', models.CharField(blank=True, max_length=100, null=True)),
                ('other2', models.CharField(blank=True, max_length=100, null=True)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Usertype',
            fields=[
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('user_type', models.CharField(choices=[('Staff', 'Staff'), ('Vendor', 'Vendor'), ('Customer', 'Customer')], default=None, max_length=100, null=True)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Pages',
            fields=[
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('page_name', models.CharField(blank=True, max_length=100, null=True)),
                ('page_description', models.CharField(blank=True, max_length=100, null=True)),
                ('app_id', models.ForeignKey(default='', on_delete=django.db.models.deletion.CASCADE, to='newops.Application')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Device',
            fields=[
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('device_type', models.CharField(choices=[('Edge', 'Edge'), ('Hardware Gateway', 'Hardware Gateway'), ('Software Gateway', 'Software Gateway'), ('Embedded Device', 'Embedded Device'), ('Other', 'Other')], default=None, max_length=100, null=True)),
                ('enrollment_type', models.CharField(choices=[('Group', 'Group'), ('Individual', 'Individual')], default=None, max_length=100, null=True)),
                ('device_registration_name', models.CharField(blank=True, max_length=100, null=True)),
                ('allocation_policy', models.CharField(choices=[('1', 'Lowest Latency'), ('2', 'Weight Distributed'), ('3', 'Static Configuration'), ('4', 'Custom(azure function)')], default=None, max_length=100, null=True)),
                ('secret_storage', models.CharField(choices=[('HSM', 'HSM'), ('TSM', 'TSM'), ('MEMORY', 'MEMORY')], default=None, max_length=100, null=True)),
                ('operation', models.CharField(choices=[('Register', 'Register'), ('Reregister', 'Reregister'), ('Delete', 'Delete')], default=None, max_length=100, null=True)),
                ('make', models.CharField(blank=True, max_length=100, null=True)),
                ('model', models.CharField(blank=True, max_length=100, null=True)),
                ('serial_number', models.CharField(blank=True, max_length=100, null=True)),
                ('date_of_purchase', models.DateField(blank=True, null=True)),
                ('warrenty_period', models.CharField(choices=[('1', '1'), ('2', '2'), ('3', '3')], default=None, max_length=100, null=True)),
                ('warrenty_expiry', models.DateField(blank=True, null=True)),
                ('Firmware_version', models.CharField(blank=True, max_length=100, null=True)),
                ('configured', models.CharField(choices=[('Yes', 'Yes'), ('No', 'No')], default=None, max_length=100, null=True)),
                ('device_IAM_mechanism', models.ManyToManyField(to='newops.Device_IAM_Mechanism')),
                ('device_Specification_ID', models.ForeignKey(default='', null=True, on_delete=django.db.models.deletion.CASCADE, to='newops.DeviceSpecification')),
                ('dps_property_ID', models.ForeignKey(default='', null=True, on_delete=django.db.models.deletion.CASCADE, to='newops.DPS_Property')),
                ('iot_hub_name', models.ForeignKey(default='', null=True, on_delete=django.db.models.deletion.CASCADE, to='newops.IOT_Hub')),
                ('route_to_application', models.ForeignKey(default='', null=True, on_delete=django.db.models.deletion.CASCADE, to='newops.Application')),
                ('sold_to_customer', models.ForeignKey(default='', null=True, on_delete=django.db.models.deletion.CASCADE, to='newops.Customer')),
                ('vendor', models.ForeignKey(default='', null=True, on_delete=django.db.models.deletion.CASCADE, to='newops.Vendor')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Certificate',
            fields=[
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('certificate_name', models.CharField(blank=True, max_length=100, null=True)),
                ('certFile_type', models.BooleanField(default=False)),
                ('generatedOn', models.DateTimeField(blank=True, null=True)),
                ('validity', models.DurationField(blank=True, null=True)),
                ('uploadedOn', models.DateTimeField(blank=True, null=True)),
                ('assigned', models.BooleanField(default=False)),
                ('assignedDate', models.DateTimeField(blank=True, null=True)),
                ('assignedTo', models.ForeignKey(default='', null=True, on_delete=django.db.models.deletion.CASCADE, to='newops.Device')),
                ('ca_name', models.ForeignKey(default='', null=True, on_delete=django.db.models.deletion.CASCADE, to='newops.CA')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='AssetGroup',
            fields=[
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('assestname', models.CharField(blank=True, max_length=100, null=True)),
                ('Customer_ID', models.ForeignKey(default='', on_delete=django.db.models.deletion.CASCADE, to='newops.Customer')),
                ('appname', models.ManyToManyField(to='newops.Application')),
                ('devicename', models.ManyToManyField(to='newops.Device')),
                ('pagename', models.ManyToManyField(to='newops.Pages')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.AddField(
            model_name='user',
            name='asset_group',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='newops.AssetGroup'),
        ),
        migrations.AddField(
            model_name='user',
            name='customer',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='newops.Customer'),
        ),
        migrations.AddField(
            model_name='user',
            name='permission_id',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='newops.Permissions'),
        ),
        migrations.AddField(
            model_name='user',
            name='user_group',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='newops.UserGroup'),
        ),
    ]
예제 #5
0
class Migration(migrations.Migration):

    dependencies = [
        ('lessons', '0012_triallesson'),
        ('products', '0001_squashed_0004_auto_20160701_0401'),
    ]

    operations = [
        migrations.CreateModel(
            name='SimpleSubscription',
            fields=[
                ('id',
                 models.AutoField(serialize=False,
                                  verbose_name='ID',
                                  primary_key=True,
                                  auto_created=True)),
                ('active',
                 models.IntegerField(choices=[(0, 'Inactive'), (1, 'Active')],
                                     default=1)),
                ('cost_currency',
                 djmoney.models.fields.CurrencyField(
                     max_length=3,
                     default='USD',
                     choices=[
                         ('AFN', 'Afghani'), ('DZD', 'Algerian Dinar'),
                         ('ARS', 'Argentine Peso'), ('AMD', 'Armenian Dram'),
                         ('AWG', 'Aruban Guilder'),
                         ('AUD', 'Australian Dollar'),
                         ('AZN', 'Azerbaijanian Manat'),
                         ('BSD', 'Bahamian Dollar'), ('BHD', 'Bahraini Dinar'),
                         ('THB', 'Baht'), ('BBD', 'Barbados Dollar'),
                         ('BYR', 'Belarussian Ruble'),
                         ('BZD', 'Belize Dollar'),
                         ('BMD',
                          'Bermudian Dollar (customarily known as Bermuda Dollar)'
                          ), ('BTN', 'Bhutanese ngultrum'),
                         ('VEF', 'Bolivar Fuerte'),
                         ('XBA',
                          'Bond Markets Units European Composite Unit (EURCO)'
                          ), ('BRL', 'Brazilian Real'),
                         ('BND', 'Brunei Dollar'), ('BGN', 'Bulgarian Lev'),
                         ('BIF', 'Burundi Franc'), ('XOF', 'CFA Franc BCEAO'),
                         ('XAF', 'CFA franc BEAC'), ('XPF', 'CFP Franc'),
                         ('CAD', 'Canadian Dollar'),
                         ('CVE', 'Cape Verde Escudo'),
                         ('KYD', 'Cayman Islands Dollar'),
                         ('CLP', 'Chilean peso'),
                         ('XTS',
                          'Codes specifically reserved for testing purposes'),
                         ('COP', 'Colombian peso'), ('KMF', 'Comoro Franc'),
                         ('CDF', 'Congolese franc'),
                         ('BAM', 'Convertible Marks'), ('NIO', 'Cordoba Oro'),
                         ('CRC', 'Costa Rican Colon'), ('HRK',
                                                        'Croatian Kuna'),
                         ('CUP', 'Cuban Peso'),
                         ('CUC', 'Cuban convertible peso'),
                         ('CZK', 'Czech Koruna'), ('GMD', 'Dalasi'),
                         ('DKK', 'Danish Krone'), ('MKD', 'Denar'),
                         ('DJF', 'Djibouti Franc'), ('STD', 'Dobra'),
                         ('DOP', 'Dominican Peso'), ('VND', 'Dong'),
                         ('XCD', 'East Caribbean Dollar'),
                         ('EGP', 'Egyptian Pound'), ('ETB', 'Ethiopian Birr'),
                         ('EUR', 'Euro'),
                         ('XBB', 'European Monetary Unit (E.M.U.-6)'),
                         ('XBD', 'European Unit of Account 17(E.U.A.-17)'),
                         ('XBC', 'European Unit of Account 9(E.U.A.-9)'),
                         ('FKP', 'Falkland Islands Pound'),
                         ('FJD', 'Fiji Dollar'), ('HUF', 'Forint'),
                         ('GHS', 'Ghana Cedi'), ('GIP', 'Gibraltar Pound'),
                         ('XAU', 'Gold'), ('XFO', 'Gold-Franc'),
                         ('PYG', 'Guarani'), ('GNF', 'Guinea Franc'),
                         ('GYD', 'Guyana Dollar'), ('HTG', 'Haitian gourde'),
                         ('HKD', 'Hong Kong Dollar'), ('UAH', 'Hryvnia'),
                         ('ISK', 'Iceland Krona'), ('INR', 'Indian Rupee'),
                         ('IRR', 'Iranian Rial'), ('IQD', 'Iraqi Dinar'),
                         ('IMP', 'Isle of Man pount'),
                         ('JMD', 'Jamaican Dollar'), ('JOD',
                                                      'Jordanian Dinar'),
                         ('KES', 'Kenyan Shilling'), ('PGK', 'Kina'),
                         ('LAK', 'Kip'), ('KWD', 'Kuwaiti Dinar'),
                         ('AOA', 'Kwanza'), ('MMK', 'Kyat'), ('GEL', 'Lari'),
                         ('LVL', 'Latvian Lats'), ('LBP', 'Lebanese Pound'),
                         ('ALL', 'Lek'), ('HNL', 'Lempira'), ('SLL', 'Leone'),
                         ('LSL', 'Lesotho loti'), ('LRD', 'Liberian Dollar'),
                         ('LYD', 'Libyan Dinar'), ('SZL', 'Lilangeni'),
                         ('LTL', 'Lithuanian Litas'), ('MGA',
                                                       'Malagasy Ariary'),
                         ('MWK', 'Malawian Kwacha'),
                         ('MYR', 'Malaysian Ringgit'), ('TMM', 'Manat'),
                         ('MUR', 'Mauritius Rupee'), ('MZN', 'Metical'),
                         ('MXN', 'Mexican peso'), ('MDL', 'Moldovan Leu'),
                         ('MAD', 'Moroccan Dirham'), ('NGN', 'Naira'),
                         ('ERN', 'Nakfa'), ('NAD', 'Namibian Dollar'),
                         ('NPR', 'Nepalese Rupee'),
                         ('ANG', 'Netherlands Antillian Guilder'),
                         ('ILS', 'New Israeli Sheqel'), ('RON', 'New Leu'),
                         ('TWD', 'New Taiwan Dollar'),
                         ('NZD',
                          'New Zealand Dollar'), ('KPW', 'North Korean Won'),
                         ('NOK', 'Norwegian Krone'), ('PEN', 'Nuevo Sol'),
                         ('MRO', 'Ouguiya'), ('TOP', 'Paanga'),
                         ('PKR', 'Pakistan Rupee'), ('XPD', 'Palladium'),
                         ('MOP', 'Pataca'), ('PHP', 'Philippine Peso'),
                         ('XPT', 'Platinum'), ('GBP', 'Pound Sterling'),
                         ('BWP', 'Pula'), ('QAR', 'Qatari Rial'),
                         ('GTQ', 'Quetzal'), ('ZAR', 'Rand'),
                         ('OMR', 'Rial Omani'), ('KHR', 'Riel'),
                         ('MVR', 'Rufiyaa'), ('IDR', 'Rupiah'),
                         ('RUB', 'Russian Ruble'), ('RWF', 'Rwanda Franc'),
                         ('XDR', 'SDR'), ('SHP', 'Saint Helena Pound'),
                         ('SAR', 'Saudi Riyal'), ('RSD', 'Serbian Dinar'),
                         ('SCR', 'Seychelles Rupee'), ('XAG', 'Silver'),
                         ('SGD', 'Singapore Dollar'),
                         ('SBD', 'Solomon Islands Dollar'), ('KGS', 'Som'),
                         ('SOS', 'Somali Shilling'), ('TJS', 'Somoni'),
                         ('LKR', 'Sri Lanka Rupee'), ('SDG', 'Sudanese Pound'),
                         ('SRD', 'Surinam Dollar'), ('SEK', 'Swedish Krona'),
                         ('CHF', 'Swiss Franc'), ('SYP', 'Syrian Pound'),
                         ('BDT', 'Taka'), ('WST', 'Tala'),
                         ('TZS', 'Tanzanian Shilling'), ('KZT', 'Tenge'),
                         ('TTD', 'Trinidad and Tobago Dollar'),
                         ('MNT', 'Tugrik'), ('TND', 'Tunisian Dinar'),
                         ('TRY', 'Turkish Lira'), ('TVD', 'Tuvalu dollar'),
                         ('AED', 'UAE Dirham'), ('XFU', 'UIC-Franc'),
                         ('USD', 'US Dollar'), ('UGX', 'Uganda Shilling'),
                         ('UYU', 'Uruguayan peso'), ('UZS', 'Uzbekistan Sum'),
                         ('VUV', 'Vatu'), ('KRW', 'Won'), ('YER',
                                                           'Yemeni Rial'),
                         ('JPY', 'Yen'), ('CNY', 'Yuan Renminbi'),
                         ('ZMK', 'Zambian Kwacha'), ('ZMW', 'Zambian Kwacha'),
                         ('ZWD', 'Zimbabwe Dollar A/06'),
                         ('ZWN', 'Zimbabwe dollar A/08'),
                         ('ZWL', 'Zimbabwe dollar A/09'), ('PLN', 'Zloty')
                     ],
                     editable=False)),
                ('name', models.CharField(max_length=140)),
                ('internal_name', models.CharField(max_length=140)),
                ('cost',
                 djmoney.models.fields.MoneyField(decimal_places=2,
                                                  default_currency='USD',
                                                  max_digits=10,
                                                  default=Decimal('0.0'))),
                ('duration',
                 models.DurationField(default=datetime.timedelta(42))),
                ('lessons_with_native',
                 models.ManyToManyField(to='lessons.LessonWithNative')),
                ('ordinary_lessons',
                 models.ManyToManyField(to='lessons.OrdinaryLesson')),
                ('paired_lessons',
                 models.ManyToManyField(to='lessons.PairedLesson')),
            ],
            options={
                'abstract': False,
                'verbose_name': 'Subscription type: beginners subscription',
                'verbose_name_plural': 'Beginner subscriptions',
            },
        ),
        migrations.RunPython(createSimpleSubscription)
    ]
예제 #6
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('tethys_compute', '0001_initial_30'),
    ]

    operations = [
        migrations.CreateModel(
            name='UitPlusJob',
            fields=[
                ('tethysjob_ptr',
                 models.OneToOneField(
                     auto_created=True,
                     on_delete=django.db.models.deletion.CASCADE,
                     parent_link=True,
                     primary_key=True,
                     serialize=False,
                     to='tethys_compute.TethysJob')),
                ('job_id', models.CharField(max_length=1024, null=True)),
                ('archive_input_files',
                 django.contrib.postgres.fields.ArrayField(
                     base_field=models.CharField(max_length=2048, null=True),
                     null=True,
                     size=None)),
                ('home_input_files',
                 django.contrib.postgres.fields.ArrayField(
                     base_field=models.CharField(max_length=2048, null=True),
                     null=True,
                     size=None)),
                ('transfer_input_files',
                 django.contrib.postgres.fields.ArrayField(
                     base_field=models.CharField(max_length=2048, null=True),
                     null=True,
                     size=None)),
                ('project_id', models.CharField(max_length=1024)),
                ('num_nodes', models.IntegerField(default=1)),
                ('processes_per_node', models.IntegerField(default=1)),
                ('max_time', models.DurationField()),
                ('queue', models.CharField(default='debug', max_length=100)),
                ('node_type',
                 models.CharField(choices=[('transfer', 'transfer'),
                                           ('compute', 'compute'),
                                           ('bigmem', 'bigmem'),
                                           ('gpu', 'gpu'), ('knl', 'knl')],
                                  default='compute',
                                  max_length=10)),
                ('system',
                 models.CharField(choices=[('jim', 'jim'), ('onyx', 'onyx')],
                                  default='onyx',
                                  max_length=10)),
                ('execution_block', models.TextField()),
                ('archive_output_files',
                 django.contrib.postgres.fields.ArrayField(
                     base_field=models.CharField(max_length=2048, null=True),
                     null=True,
                     size=None)),
                ('home_output_files',
                 django.contrib.postgres.fields.ArrayField(
                     base_field=models.CharField(max_length=2048, null=True),
                     null=True,
                     size=None)),
                ('intermediate_transfer_interval',
                 models.IntegerField(default=0)),
                ('last_intermediate_transfer',
                 models.DateTimeField(default=django.utils.timezone.now)),
                ('max_cleanup_time',
                 models.DurationField(default=datetime.timedelta(
                     seconds=3600))),
                ('transfer_intermediate_files',
                 django.contrib.postgres.fields.ArrayField(
                     base_field=models.CharField(max_length=2048, null=True),
                     null=True,
                     size=None)),
                ('transfer_job_script', models.BooleanField(default=True)),
                ('transfer_output_files',
                 django.contrib.postgres.fields.ArrayField(
                     base_field=models.CharField(max_length=2048, null=True),
                     null=True,
                     size=None)),
                ('_modules',
                 django.contrib.postgres.fields.jsonb.JSONField(null=True)),
                ('_optional_directives',
                 django.contrib.postgres.fields.ArrayField(
                     base_field=models.CharField(max_length=2048, null=True),
                     size=None)),
                ('_process_intermediate_results_function',
                 models.CharField(max_length=1024, null=True)),
                ('_remote_workspace', models.TextField(blank=True)),
                ('_remote_workspace_id', models.CharField(max_length=100)),
                ('_environment_variables',
                 django.contrib.postgres.fields.jsonb.JSONField(null=True)),
                ('_array_indices',
                 django.contrib.postgres.fields.ArrayField(
                     base_field=models.IntegerField(), null=True, size=None)),
            ],
            bases=(uit.pbs_script.PbsScript, 'tethys_compute.tethysjob'),
        ),
    ]
예제 #7
0
class ServiceEvent(models.Model):

    unit_service_area = models.ForeignKey(
        UnitServiceArea,
        on_delete=models.PROTECT,
        verbose_name=_l("unit service area"),
    )
    service_type = models.ForeignKey(
        ServiceType,
        on_delete=models.PROTECT,
        verbose_name=_l("service type"),
    )
    service_event_related = models.ManyToManyField(
        'self',
        symmetrical=True,
        blank=True,
        verbose_name=_l('related service events'),
        help_text=_l(
            'Enter the service event IDs of any related service events.'))
    service_status = models.ForeignKey(
        ServiceEventStatus,
        verbose_name=_l('status'),
        on_delete=models.PROTECT,
        help_text=_l("The current status of this service event"),
    )

    user_status_changed_by = models.ForeignKey(
        User,
        null=True,
        blank=True,
        related_name='+',
        on_delete=models.PROTECT,
        verbose_name=_l("status last changed by"))
    user_created_by = models.ForeignKey(
        User,
        related_name='+',
        on_delete=models.PROTECT,
        verbose_name=_l("created by"),
    )
    user_modified_by = models.ForeignKey(
        User,
        null=True,
        blank=True,
        related_name='+',
        on_delete=models.PROTECT,
        verbose_name=_l("modified by"),
    )
    test_list_instance_initiated_by = models.ForeignKey(
        q_models.TestListInstance,
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='serviceevents_initiated',
        verbose_name=_l("initiating test list instance"),
    )
    service_event_template = models.ForeignKey(
        'ServiceEventTemplate',
        blank=True,
        null=True,
        on_delete=models.PROTECT,
        verbose_name=_l("service event template"),
    )
    service_event_schedule = models.ForeignKey(
        'ServiceEventSchedule',
        blank=True,
        null=True,
        on_delete=models.PROTECT,
        verbose_name=_l("service event schedule"),
    )
    due_date = models.DateTimeField(
        null=True,
        blank=True,
        help_text=_l('When was this service event due when it was performed'),
    )

    include_for_scheduling = models.BooleanField(
        help_text=_l(
            "Should this instance be considered when calculating due dates?"),
        default=True,
    )

    datetime_status_changed = models.DateTimeField(
        _l("status changed"),
        null=True,
        blank=True,
    )
    datetime_created = models.DateTimeField(_l("created"), )
    datetime_service = models.DateTimeField(
        verbose_name=_l('Date and time'),
        help_text=_l('Date and time service performed'))
    datetime_modified = models.DateTimeField(
        _l("modified"),
        null=True,
        blank=True,
    )

    safety_precautions = models.TextField(
        _l("safety precautions"),
        null=True,
        blank=True,
        help_text=_l('Describe any safety precautions taken'),
    )
    problem_description = models.TextField(
        _l("problem description"),
        help_text=_l('Describe the problem leading to this service event'),
    )
    work_description = models.TextField(
        _l("work description"),
        null=True,
        blank=True,
        help_text=_l('Describe the work done during this service event'),
    )
    duration_service_time = models.DurationField(
        verbose_name=_l('Service time'),
        null=True,
        blank=True,
        help_text=_l(
            'Enter the total time duration of this service event (Hours : minutes)'
        ),
    )
    duration_lost_time = models.DurationField(
        verbose_name=_l('Lost time'),
        null=True,
        blank=True,
        help_text=_l(
            'Enter the total clinical time lost for this service event (Hours : minutes)'
        ),
    )
    is_review_required = models.BooleanField(
        _l("review required"),
        default=True,
        blank=True,
    )
    is_active = models.BooleanField(
        _l("is active"),
        default=True,
        blank=True,
    )

    objects = ServiceEventManager()
    all_objects = models.Manager()

    class Meta:
        verbose_name = _l('service event')
        verbose_name_plural = _l('service events')
        get_latest_by = "datetime_service"

        permissions = (
            ('review_serviceevent', _l('Can review service event')),
            ('view_serviceevent', _l('Can review service event')),
        )
        default_permissions = (
            'add',
            'change',
            'delete',
        )

        ordering = ["-datetime_service"]

    def __str__(self):
        return str(self.id)

    @property
    def work_completed(self):
        return self.datetime_service

    def create_rts_log_details(self):
        rts_states = []
        for r in self.returntoserviceqa_set.all():

            utc = r.unit_test_collection
            if not r.test_list_instance:
                state = 'tli_incomplete'
                details = utc.name
            elif not r.test_list_instance.all_reviewed:
                state = 'tli_req_review'
                details = r.test_list_instance.test_list.name
            else:
                state = 'tli_reviewed'
                details = r.test_list_instance.test_list.name

            rts_states.append({'state': state, 'details': details})
        return rts_states

    def set_inactive(self):
        self.is_active = False
        self.save()

        parts_used = self.partused_set.all()
        for pu in parts_used:
            pu.add_back_to_storage()

    def set_active(self):
        self.is_active = True
        self.save()

        parts_used = self.partused_set.all()
        for pu in parts_used:
            pu.remove_from_storage()

    def get_absolute_url(self):
        return reverse("sl_details", kwargs={"pk": self.pk})
예제 #8
0
class RunStats(models.Model):
    """
    Hold all meta-information on topic model runs
    """
    run_id = models.AutoField(primary_key=True)

    ##Inputs

    ONLINE = "on"
    BATCH = "ba"
    lda_choices = (
        (ONLINE, 'Online'),
        (BATCH, 'Batch'),
    )
    SKLEARN = "sk"
    LDA_LIB = "ld"
    WARP = "wl"
    lda_libs = ((SKLEARN, "Sklearn"), (LDA_LIB, "lda"), (WARP, "warplda"))

    max_features = models.IntegerField(
        default=0, help_text='Maximum number of terms (0 = no limit)')
    min_freq = models.IntegerField(default=1,
                                   help_text='Minimum frequency of terms')
    max_df = MinMaxFloat(default=0.95, min_value=0.0, max_value=1.0)
    limit = models.IntegerField(
        null=True,
        default=0,
        help_text=
        'Limit model to first x documents (leave as zero for no limit)')
    ngram = models.IntegerField(null=True,
                                default=1,
                                help_text='Length of feature n_gram')
    db = models.BooleanField(
        default=True,
        help_text=
        'Record the results into the database? Or just run the model and record statistics?'
    )

    fancy_tokenization = models.BooleanField(
        default=False,
        help_text='tokenize so that multiple word keywords remain whole')

    K = models.IntegerField(null=True, help_text='Number of topics')
    alpha = models.FloatField(
        null=True,
        default=0.01,
        help_text=
        'Concentration parameter of Dirichlet distribution of topics in documents'
        ' (try higher values in LDA, including > 1). Low (high) values indicate that'
        ' documents should be composed of few (many) topics. Also called theta.'
        ' In NMF, this is the regularization term alpha')
    beta = models.FloatField(
        null=True,
        blank=True,
        default=None,
        help_text=
        'Concentration parameter of Dirichlet distribution of words in topics.'
        ' Low (high) values indicate that topics should be composed of few (many) words.'
        ' Also called eta. This parameter is not used in NMF')
    lda_learning_method = models.CharField(
        max_length=2,
        choices=lda_choices,
        null=True,
        default=BATCH,
        help_text=
        'When using LDA in sklearn, you can choose between batch or online learning'
    )
    lda_library = models.CharField(
        max_length=2,
        choices=lda_libs,
        null=True,
        default=SKLEARN,
        help_text=
        'you can use sklearn or https://github.com/lda-project/lda for LDA')
    top_chain_var = models.FloatField(null=True,
                                      default=0.05,
                                      help_text='Chain var parameter for dtm')
    max_iter = models.IntegerField(null=True,
                                   default=200,
                                   help_text='Maximum iterations')
    rng_seed = models.IntegerField(
        null=True,
        help_text=
        "seed for random number generator for stochastic estimation of topic model (blei dtm)"
    )
    fulltext = models.BooleanField(
        default=False,
        help_text='do analysis on fullText? (dependent on availability)')
    citations = models.BooleanField(
        default=False, help_text='scale term scores by citations?')

    # Additional information
    language = models.TextField(
        null=True,
        help_text=
        'language of the documents that have been analyzed (also used for stopword identification)'
    )
    extra_stopwords = ArrayField(
        models.TextField(),
        null=True,
        help_text=
        'list of stopwords that are used additionally to the standard ones')

    query = models.ForeignKey(
        'scoping.Query',
        null=True,
        on_delete=models.CASCADE,
        help_text='relation to the scoping search object')
    psearch = models.ForeignKey(
        'parliament.Search',
        null=True,
        on_delete=models.CASCADE,
        help_text='relation to the parliamentary search object')

    ## Progress
    process_id = models.IntegerField(null=True)
    start = models.DateTimeField(auto_now_add=True)
    batch_count = models.IntegerField(default=0)
    last_update = models.DateTimeField(auto_now_add=True)
    topic_titles_current = models.NullBooleanField(default=False)
    topic_scores_current = models.NullBooleanField(default=False)
    topic_year_scores_current = models.NullBooleanField(default=False)

    ## Time spent
    runtime = models.DurationField(null=True)
    nmf_time = models.FloatField(default=0)
    tfidf_time = models.FloatField(default=0)
    db_time = models.FloatField(default=0)

    status_choices = ((0, 'Not Started'), (1, 'Running'), (2, 'Interrupted'),
                      (3, 'Finished'))
    status = models.IntegerField(choices=status_choices,
                                 default=0,
                                 help_text='status of the model execution')

    parent_run_id = models.IntegerField(null=True, help_text='')

    docs_seen = models.IntegerField(null=True)
    notes = models.TextField(null=True)
    LDA = 'LD'
    HLDA = 'HL'
    DTM = 'DT'
    NMF = 'NM'
    BDT = 'BD'
    METHOD_CHOICES = ((LDA, 'lda'), (HLDA, 'hlda'), (DTM, 'dnmf'),
                      (NMF, 'nmf'), (BDT, 'BleiDTM'))
    method = models.CharField(
        max_length=2,
        choices=METHOD_CHOICES,
        default=NMF,
    )
    error = models.FloatField(null=True, default=0)
    coherence = models.FloatField(null=True)
    errortype = models.TextField(null=True)
    exclusivity = models.FloatField(null=True)

    empty_topics = models.IntegerField(null=True)

    iterations = models.IntegerField(null=True)

    max_topics = models.IntegerField(null=True)
    term_count = models.IntegerField(null=True)
    periods = models.ManyToManyField('TimePeriod')

    doc_topic_scaled_score = models.BooleanField(default=False)
    dt_threshold = models.FloatField(default=0.0005)
    dt_threshold_scaled = models.FloatField(default=0.01)
    dyn_win_threshold = models.FloatField(default=0.1)

    def check_partitions(s):

        run_id = RunStats.objects.last().pk + 1
        sql = """
        select relname, pg_get_expr(relpartbound, oid), substring(pg_get_expr(relpartbound, oid) from '\d+')::int AS s
        from pg_class
        WHERE relispartition and relname~'tmv_app_doctopic'
        AND pg_get_expr(relpartbound, oid)~'FOR VALUES' ORDER BY s DESC LIMIT 1;
        """
        with connection.cursor() as cursor:
            cursor.execute(sql)
            row = cursor.fetchone()
            pname = row[0]
            vrange = re.findall('\d+', row[1])
            sql = f"SELECT COUNT(id) FROM {row[0]}"
            cursor.execute(sql)
            row = cursor.fetchone()
            if run_id < int(vrange[1]):
                if row[0] > 10000000:
                    # Alter current partition
                    sql = f"""BEGIN TRANSACTION;
                    ALTER TABLE tmv_app_doctopic DETACH PARTITION {pname};
                    ALTER TABLE tmv_app_doctopic ATTACH PARTITION {pname}
                    FOR VALUES FROM ({vrange[0]}) TO ({run_id});
                    COMMIT TRANSACTION;"""
                    cursor.execute(sql)
                else:
                    return
                # Create new partition
                connection.schema_editor().add_range_partition(
                    model=DocTopic,
                    name=f"pt_{run_id}",
                    from_values=run_id,
                    to_values=run_id + 10000)
            else:
                connection.schema_editor().add_range_partition(
                    model=DocTopic,
                    name=f"pt_{run_id}",
                    from_values=run_id,
                    to_values=run_id + 10000)

    def save(self, *args, **kwargs):
        self.check_partitions()
        if not self.parent_run_id:
            self.parent_run_id = self.run_id
        super(RunStats, self).save(*args, **kwargs)

    def dt_matrix(self, path, s_size=0, force_overwrite=False):
        '''
        Return a sparse doctopic matrix and its row and column ids
        '''
        # see if the required objects already exist
        mpath = f"{path}/run_{self.pk}_s_{s_size}_m.npy"
        rpath = f"{path}/run_{self.pk}_s_{s_size}_r_ind.npy"
        cpath = f"{path}/run_{self.pk}_s_{s_size}_c_ind.npy"
        if os.path.exists(mpath):
            m = np.load(mpath, allow_pickle=True)[()]
            if os.path.exists(rpath):
                r_ind = np.load(rpath, allow_pickle=True)
                if os.path.exists(cpath):
                    c_ind = np.load(cpath, allow_pickle=True)
                    if not force_overwrite:
                        print(
                            "We've already calculated the required matrices!")
                        return (m, c_ind, r_ind)

        if self.method == "DT":
            dts = DocDynamicTopic.objects
        else:
            dts = DocTopic.objects

        if self.query:
            doc_id_var = 'doc__id'
        elif self.psearch:
            if self.psearch.search_object_type == parliament.models.Search.PARAGRAPH:
                doc_id_var = 'par__id'
            elif self.psearch.search_object_type == parliament.models.Search.UTTERANCE:
                doc_id_var = 'ut__id'
        else:
            print("I don't know what type of document I have...")
            return

        db_matrix = dts.filter(run_id=self.pk, score__gt=self.dt_threshold)
        docs = set(db_matrix.values_list(doc_id_var, flat=True))

        if s_size > 0:
            s_docs = random.sample(docs, s_size)
            db_matrix = dts.filter(run_id=stat.pk,
                                   score__gt=0.01,
                                   doc__id__in=s_docs)
        vs = list(db_matrix.values('score', doc_id_var, 'topic_id'))

        c_ind = np.array(
            list(
                set(
                    db_matrix.values_list('topic_id',
                                          flat=True).order_by(doc_id_var))))
        r_ind = np.array(
            list(
                set(
                    db_matrix.values_list(doc_id_var,
                                          flat=True).order_by(doc_id_var))))

        d = [x['score'] for x in vs]
        c = [int(np.where(c_ind == x['topic_id'])[0]) for x in vs]
        r = [int(np.where(r_ind == x[doc_id_var])[0]) for x in vs]

        m = coo_matrix((d, (r, c)), shape=(len(r_ind), len(c_ind)))

        np.save(mpath, m)
        np.save(rpath, r_ind)
        np.save(cpath, c_ind)

        return (m, c_ind, r_ind)

    def calculate_tsne(self, path, p, s_size=0, force_overwrite=False):
        """
        Function applied to RunStats object to calculate dimensionality reduction using TSNE

        :param path: Results path
        :param p:
        :param s_size:
        :param force_overwrite: (default: False) Overrides already existing results
        :return:
        """
        m, c_ind, r_ind = self.dt_matrix(path, s_size)
        results_path = f"{path}/run_{self.pk}_s_{s_size}_p_{p}_results.npy"
        if os.path.exists(results_path):
            tsne_results = np.load(results_path, allow_pickle=True)
            if not force_overwrite:
                print("We've already calculated the tsne positions")
                return tsne_results, r_ind
        tsne = mTSNE(n_components=2, verbose=0, perplexity=p, n_jobs=4)
        tsne_results = tsne.fit_transform(m.toarray())
        np.save(results_path, tsne_results)
        return tsne_results, r_ind
예제 #9
0
class AllFields(models.Model):
    # basics
    field_int = models.IntegerField()
    field_float = models.FloatField()
    field_bool = models.BooleanField()
    field_char = models.CharField(max_length=100)
    field_text = models.TextField()
    # special
    field_slug = models.SlugField()
    field_email = models.EmailField()
    field_uuid = models.UUIDField()
    field_url = models.URLField()
    if models.IPAddressField in serializers.ModelSerializer.serializer_field_mapping:
        field_ip = models.IPAddressField()
    else:
        field_ip = models.GenericIPAddressField(protocol='ipv6')
    field_ip_generic = models.GenericIPAddressField(protocol='ipv6')
    field_decimal = models.DecimalField(max_digits=6, decimal_places=3)
    field_file = models.FileField(storage=fs)
    field_img = models.ImageField(storage=fs)
    field_date = models.DateField()
    field_datetime = models.DateTimeField()
    field_bigint = models.BigIntegerField()
    field_smallint = models.SmallIntegerField()
    field_posint = models.PositiveIntegerField()
    field_possmallint = models.PositiveSmallIntegerField()
    field_nullbool = models.NullBooleanField()
    field_time = models.TimeField()
    field_duration = models.DurationField()

    # relations
    field_foreign = models.ForeignKey(Aux, on_delete=models.CASCADE, help_text='main aux object')
    field_m2m = models.ManyToManyField(Aux, help_text='set of related aux objects')
    field_o2o = models.OneToOneField(Aux, on_delete=models.CASCADE, help_text='bound aux object')
    # overrides
    field_regex = models.CharField(max_length=50)
    field_bool_override = models.BooleanField()

    if DJANGO_VERSION >= '3.1':
        field_json = models.JSONField()
    else:
        @property
        def field_json(self):
            return {'A': 1, 'B': 2}

    @property
    def field_model_property_float(self) -> float:
        return 1.337

    @cached_property
    def field_model_cached_property_float(self) -> float:
        return 1.337

    @property
    def field_list(self):
        return [1.1, 2.2, 3.3]

    @property
    def field_list_object(self):
        return self.field_m2m.all()

    def model_function_basic(self) -> bool:
        return True

    def model_function_model(self) -> Aux:
        return self.field_foreign
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Customer',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('nazwa', models.CharField(max_length=200, null=True)),
                ('email', models.CharField(max_length=200, null=True)),
                ('uzytkownik', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Dodatkowe',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('ilosc', models.IntegerField()),
            ],
        ),
        migrations.CreateModel(
            name='Przepis',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('nazwa', models.CharField(max_length=64, unique=True)),
                ('opis', models.TextField(blank=True, default='', null=True)),
                ('krotki_opis', models.TextField(blank=True, default='', null=True)),
                ('przygotowanie', models.TextField(blank=True, default='', null=True)),
                ('skladniki_ilosc', models.TextField(blank=True, default='', null=True)),
                ('zdjecie', models.ImageField(blank=True, null=True, upload_to='zdjecia')),
                ('data_dodania', models.DateField(auto_now_add=True)),
                ('edytowane', models.DateField(auto_now=True)),
                ('czas_przygotowania', models.DurationField(blank=True, default=0)),
                ('stopien_trudnosci', models.DecimalField(decimal_places=2, max_digits=4)),
            ],
        ),
        migrations.CreateModel(
            name='Skladniki',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('nazwa', models.CharField(max_length=64, unique=True)),
                ('typ', models.PositiveSmallIntegerField(choices=[(2, 'Przyprawa'), (3, 'Mieso'), (6, 'Owoce morza'), (5, 'Owoc'), (1, 'Warzywo'), (4, 'Ryba'), (0, 'brak wybranego typu')], default=0)),
            ],
        ),
        migrations.CreateModel(
            name='Zakupy',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('data_utworzenia', models.DateTimeField(auto_now_add=True)),
                ('zakonczone', models.BooleanField(default=False, null=True)),
                ('zakupy_id', models.CharField(max_length=200, null=True)),
                ('klient', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='pracaDyplomowaAplikacja.Customer')),
            ],
        ),
        migrations.CreateModel(
            name='ZakupyElementy',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('ilosc', models.IntegerField(blank=True, default=0, null=True)),
                ('data_dodania', models.DateTimeField(auto_now_add=True)),
                ('element', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='pracaDyplomowaAplikacja.Przepis')),
                ('zakupy', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='pracaDyplomowaAplikacja.Zakupy')),
            ],
        ),
        migrations.AddField(
            model_name='przepis',
            name='skladniki',
            field=models.ManyToManyField(through='pracaDyplomowaAplikacja.Dodatkowe', to='pracaDyplomowaAplikacja.Skladniki'),
        ),
        migrations.AddField(
            model_name='dodatkowe',
            name='przepis',
            field=models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, to='pracaDyplomowaAplikacja.Przepis'),
        ),
        migrations.AddField(
            model_name='dodatkowe',
            name='skladnik',
            field=models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, to='pracaDyplomowaAplikacja.Skladniki'),
        ),
    ]
예제 #11
0
class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='SignUp',
            fields=[
                ('Name', models.CharField(max_length=264)),
                ('UserName',
                 models.CharField(max_length=264,
                                  primary_key=True,
                                  serialize=False)),
                ('Class', models.CharField(max_length=10)),
                ('Section', models.CharField(max_length=1)),
                ('Gender', models.CharField(max_length=10)),
                ('Age', models.IntegerField()),
                ('Email', models.EmailField(max_length=254)),
                ('Percentage', models.IntegerField()),
                ('Password', models.CharField(max_length=264)),
            ],
        ),
        migrations.CreateModel(
            name='Test1',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('score', models.IntegerField(blank=True, null=True)),
                ('UserName',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='login.SignUp')),
            ],
        ),
        migrations.CreateModel(
            name='Test1Question',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('Question', models.CharField(max_length=512)),
                ('yes', models.IntegerField()),
                ('no', models.IntegerField()),
                ('notSure', models.IntegerField()),
            ],
        ),
        migrations.CreateModel(
            name='Test2',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('timeReq',
                 models.DurationField(blank=True, db_index=True, null=True)),
                ('UserName',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='login.SignUp')),
            ],
        ),
    ]
class Migration(migrations.Migration):

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='ExceptionEvent',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('created', models.DateTimeField(db_index=True)),
                ('received', models.DateTimeField(db_index=True)),
                ('error_type', models.CharField(max_length=255,
                                                db_index=True)),
                ('error_data', models.TextField(default=b'')),
            ],
        ),
        migrations.CreateModel(
            name='Host',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('name', models.CharField(unique=True, max_length=255)),
                ('ip', models.GenericIPAddressField()),
                ('active', models.BooleanField(default=True)),
            ],
        ),
        migrations.CreateModel(
            name='Metric',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('name', models.CharField(max_length=255, db_index=True)),
            ],
        ),
        migrations.CreateModel(
            name='MetricLabel',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('name', models.TextField(default=b'', blank=True)),
            ],
        ),
        migrations.CreateModel(
            name='MetricValue',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('valid_from', models.DateTimeField(db_index=True)),
                ('valid_to', models.DateTimeField(db_index=True)),
                ('value', models.CharField(max_length=255)),
                ('value_num',
                 models.DecimalField(default=None,
                                     null=True,
                                     max_digits=16,
                                     decimal_places=4,
                                     blank=True)),
                ('value_raw',
                 models.TextField(default=None, null=True, blank=True)),
                ('data', jsonfield.fields.JSONField(default={})),
                ('label', models.ForeignKey(to='monitoring.MetricLabel')),
            ],
        ),
        migrations.CreateModel(
            name='MonitoredResource',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('name',
                 models.CharField(default=b'', max_length=255, blank=True)),
                ('type',
                 models.CharField(default=b'',
                                  max_length=255,
                                  choices=[(b'', b'No resource'),
                                           (b'layer', b'Layer'),
                                           (b'map', b'Map'),
                                           (b'document', b'Document'),
                                           (b'style', b'Style'),
                                           (b'admin', b'Admin'),
                                           (b'other', b'Other')])),
            ],
        ),
        migrations.CreateModel(
            name='RequestEvent',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('created', models.DateTimeField(db_index=True)),
                ('received', models.DateTimeField(db_index=True)),
                ('ows_type',
                 models.CharField(default=b'other',
                                  max_length=255,
                                  choices=[(b'TMS', b'TMS'),
                                           (b'WMS-C', b'WMS-C'),
                                           (b'WMTS', b'WMTS'),
                                           (b'WCS', b'WCS'), (b'WFS', b'WFS'),
                                           (b'WMS', b'WMS'), (b'WPS', b'WPS'),
                                           (b'other', b'Other')])),
                ('host',
                 models.CharField(default=b'', max_length=255, blank=True)),
                ('request_path', models.CharField(default=b'',
                                                  max_length=255)),
                ('resources',
                 models.TextField(
                     default=b'',
                     help_text=b'Resources name (style, layer, document, map)',
                     blank=True)),
                ('request_method',
                 models.CharField(max_length=16,
                                  choices=[(b'GET', b'GET'),
                                           (b'POST', b'POST'),
                                           (b'HEAD', b'HEAD'),
                                           (b'OPTIONS', b'OPTIONS'),
                                           (b'PUT', b'PUT'),
                                           (b'DELETE', b'DELETE')])),
                ('response_status', models.PositiveIntegerField()),
                ('response_size', models.PositiveIntegerField(default=0)),
                ('response_time',
                 models.PositiveIntegerField(
                     default=0, help_text=b'Response processing time in ms')),
                ('response_type',
                 models.CharField(default=b'',
                                  max_length=255,
                                  null=True,
                                  blank=True)),
                ('user_agent',
                 models.CharField(default=None,
                                  max_length=255,
                                  null=True,
                                  blank=True)),
                ('user_agent_family',
                 models.CharField(default=None,
                                  max_length=255,
                                  null=True,
                                  blank=True)),
                ('client_ip', models.GenericIPAddressField()),
                ('client_lat',
                 models.DecimalField(default=None,
                                     null=True,
                                     max_digits=8,
                                     decimal_places=5,
                                     blank=True)),
                ('client_lon',
                 models.DecimalField(default=None,
                                     null=True,
                                     max_digits=8,
                                     decimal_places=5,
                                     blank=True)),
                ('client_country',
                 models.CharField(default=None,
                                  max_length=255,
                                  null=True,
                                  blank=True)),
                ('client_region',
                 models.CharField(default=None,
                                  max_length=255,
                                  null=True,
                                  blank=True)),
                ('client_city',
                 models.CharField(default=None,
                                  max_length=255,
                                  null=True,
                                  blank=True)),
                ('custom_id',
                 models.CharField(default=None,
                                  max_length=255,
                                  null=True,
                                  db_index=True,
                                  blank=True)),
            ],
        ),
        migrations.CreateModel(
            name='Service',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('name', models.CharField(unique=True, max_length=255)),
                ('check_interval',
                 models.DurationField(default=datetime.timedelta(0, 60))),
                ('last_check', models.DateTimeField(null=True, blank=True)),
                ('active', models.BooleanField(default=True)),
                ('notes', models.TextField(null=True, blank=True)),
                ('url', models.URLField(default=b'', null=True, blank=True)),
                ('host', models.ForeignKey(to='monitoring.Host')),
            ],
        ),
        migrations.CreateModel(
            name='ServiceType',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('name',
                 models.CharField(unique=True,
                                  max_length=255,
                                  choices=[
                                      (b'geonode', b'GeoNode'),
                                      (b'geoserver', b'GeoServer'),
                                      (b'hostgeoserver', b'Host (GeoServer)'),
                                      (b'hostgeonode', b'Host (GeoNode)')
                                  ])),
            ],
        ),
        migrations.CreateModel(
            name='ServiceTypeMetric',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('metric', models.ForeignKey(to='monitoring.Metric')),
                ('service_type',
                 models.ForeignKey(to='monitoring.ServiceType')),
            ],
        ),
        migrations.AddField(
            model_name='service',
            name='service_type',
            field=models.ForeignKey(to='monitoring.ServiceType'),
        ),
        migrations.AddField(
            model_name='requestevent',
            name='service',
            field=models.ForeignKey(to='monitoring.Service'),
        ),
        migrations.AlterUniqueTogether(
            name='monitoredresource',
            unique_together=set([('name', 'type')]),
        ),
        migrations.AddField(
            model_name='metricvalue',
            name='resource',
            field=models.ForeignKey(to='monitoring.MonitoredResource'),
        ),
        migrations.AddField(
            model_name='metricvalue',
            name='service',
            field=models.ForeignKey(to='monitoring.Service'),
        ),
        migrations.AddField(
            model_name='metricvalue',
            name='service_metric',
            field=models.ForeignKey(to='monitoring.ServiceTypeMetric'),
        ),
        migrations.AddField(
            model_name='exceptionevent',
            name='request',
            field=models.ForeignKey(to='monitoring.RequestEvent'),
        ),
        migrations.AddField(
            model_name='exceptionevent',
            name='service',
            field=models.ForeignKey(to='monitoring.Service'),
        ),
    ]