コード例 #1
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [swapper.dependency('openwisp_users', 'Organization')]

    operations = [
        migrations.CreateModel(
            name='Config',
            fields=[
                (
                    'id',
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name='ID',
                    ),
                ),
                ('name', models.CharField(max_length=16)),
                (
                    'organization',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=swapper.get_model_name('openwisp_users',
                                                  'Organization'),
                        verbose_name='organization',
                    ),
                ),
            ],
            options={'abstract': False},
        ),
        migrations.CreateModel(
            name='Template',
            fields=[
                (
                    'id',
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name='ID',
                    ),
                ),
                ('name', models.CharField(max_length=16)),
                (
                    'organization',
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to=swapper.get_model_name('openwisp_users',
                                                  'Organization'),
                        verbose_name='organization',
                    ),
                ),
            ],
            options={'abstract': False},
        ),
    ]
コード例 #2
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        swapper.dependency('topology', 'Node'),
        swapper.dependency('config', 'Device'),
    ]

    operations = [
        migrations.CreateModel(
            name='DeviceNode',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'device',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=swapper.get_model_name('config', 'Device'),
                    ),
                ),
                (
                    'node',
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=swapper.get_model_name('topology', 'Node'),
                    ),
                ),
            ],
            options={
                'abstract':
                False,
                'swappable':
                swapper.swappable_setting('topology_device', 'DeviceNode'),
                'unique_together': {('node', 'device')},
            },
        )
    ]
class Migration(migrations.Migration):
    dependencies = [
        dependency(*split(settings.AUTH_USER_MODEL),
                   version='0004_default_groups'),
        ('topology', '0004_fixed_target_link_set'),
    ]
    operations = [
        migrations.RunPython(assign_permissions_to_groups,
                             reverse_code=migrations.RunPython.noop)
    ]
コード例 #4
0
ファイル: 0001_initial.py プロジェクト: pombredanne/wq.db
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('contenttypes', '0002_remove_content_type_name'),
        swapper.dependency('mark', 'MarkdownType'),
    ]

    operations = [
        migrations.CreateModel(
            name='MarkdownType',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=100)),
            ],
            options={
                'abstract': False,
                'swappable': swapper.swappable_setting('mark', 'MarkdownType'),
                'db_table': 'wq_markdowntype',
            },
        ),
        migrations.CreateModel(
            name='Markdown',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('summary',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('markdown', models.TextField(blank=True, null=True)),
                ('object_id', models.PositiveIntegerField()),
                ('content_type',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='contenttypes.ContentType')),
                ('type',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to=swapper.get_model_name(
                                       'mark', 'MarkdownType'))),
            ],
            options={
                'abstract': False,
                'db_table': 'wq_markdown',
            },
        ),
    ]
コード例 #5
0
class Migration(migrations.Migration):
    dependencies = [
        ('taggit', '0003_taggeditem_add_unique_index'),
        ('dataframe_store', '0001_initial'),
        swapper.dependency('dataframe_store', 'DbDataFrame'),
    ]

    operations = [
        migrations.CreateModel(
            name='DbDataFrame',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=255)),
                ('description', models.TextField(blank=True, max_length=3000)),
                ('obj', picklefield.fields.PickledObjectField(editable=False)),
                ('shape_x', models.IntegerField()),
                ('shape_y', models.IntegerField()),
                ('lft',
                 models.PositiveIntegerField(db_index=True, editable=False)),
                ('rght',
                 models.PositiveIntegerField(db_index=True, editable=False)),
                ('tree_id',
                 models.PositiveIntegerField(db_index=True, editable=False)),
                ('level',
                 models.PositiveIntegerField(db_index=True, editable=False)),
            ],
            options={
                'verbose_name_plural':
                'dataframes',
                'verbose_name':
                'dataframe',
                'abstract':
                False,
                'swappable':
                swapper.swappable_setting('dataframe_store', 'DbDataFrame')
            },
        ),
        migrations.AddField(
            model_name='dbdataframe',
            name='tags',
            field=taggit.managers.TaggableManager(
                blank=True,
                help_text='A comma-separated list of tags.',
                through='taggit.TaggedItem',
                to='taggit.Tag',
                verbose_name='Tags'),
        ),
    ]
コード例 #6
0
class Migration(migrations.Migration):

    dependencies = [
        ('check', '0006_rename_check_check_check_type'),
        swapper.dependency('monitoring', 'Metric'),
    ]

    operations = [
        migrations.RunPython(create_ping_checks,
                             reverse_code=migrations.RunPython.noop),
        migrations.RunPython(create_config_applied_checks,
                             reverse_code=remove_config_applied_checks),
    ]
コード例 #7
0
class Migration(migrations.Migration):

    dependencies = [
        ('cities', '0004_rename_languages_to_language_codes'),
        swapper.dependency('cities', 'City'),
    ]

    operations = [
        migrations.AddField(
            model_name='postalcode',
            name='city',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name='postal_codes',
                to=swapper.get_model_name('cities', 'City')),
        ),
        migrations.AddField(
            model_name='postalcode',
            name='district',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name='postal_codes',
                to='cities.District'),
        ),
        migrations.AddField(
            model_name='postalcode',
            name='region',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name='postal_codes',
                to='cities.Region'),
        ),
        migrations.AddField(
            model_name='postalcode',
            name='subregion',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name='postal_codes',
                to='cities.Subregion'),
        ),
    ]
コード例 #8
0
ファイル: 0001_initial.py プロジェクト: shaneramey/wq.db
class Migration(migrations.Migration):

    dependencies = [
        ('contenttypes', '0001_initial'),
        swapper.dependency('mark', 'MarkdownType'),
    ]

    operations = [
        migrations.CreateModel(
            name='MarkdownType',
            fields=[
                ('id',
                 models.AutoField(serialize=False,
                                  verbose_name='ID',
                                  primary_key=True,
                                  auto_created=True)),
                ('name', models.CharField(max_length=100)),
            ],
            options={
                'swappable': swapper.swappable_setting('mark', 'MarkdownType'),
                'db_table': 'wq_markdowntype',
            },
            bases=(models.Model, ),
        ),
        migrations.CreateModel(
            name='Markdown',
            fields=[
                ('id',
                 models.AutoField(serialize=False,
                                  verbose_name='ID',
                                  primary_key=True,
                                  auto_created=True)),
                ('markdown', models.TextField(blank=True, null=True)),
                ('summary',
                 models.CharField(blank=True, max_length=255, null=True)),
                ('object_id', models.PositiveIntegerField()),
                ('content_type',
                 models.ForeignKey(to='contenttypes.ContentType')),
                ('type',
                 models.ForeignKey(
                     to=swapper.get_model_name('mark', 'MarkdownType'))),
            ],
            options={
                'db_table': 'wq_markdown',
            },
            bases=(models.Model, ),
        ),
    ]
コード例 #9
0
class Migration(migrations.Migration):

    dependencies = [
        swapper.dependency('openwisp_users', 'Organization'),
        ('sample_connection', '0002_default_group_permissions'),
    ]

    operations = [
        migrations.AlterField(
            model_name='credentials',
            name='name',
            field=models.CharField(db_index=True, max_length=64),
        ),
        migrations.AlterUniqueTogether(
            name='credentials', unique_together={('name', 'organization')}
        ),
    ]
コード例 #10
0
class Migration(migrations.Migration):

    dependencies = [
        ('cities', '0001_initial'),
        swapper.dependency('cities', 'Country'),
    ]

    operations = [
        migrations.CreateModel(
            name='Continent',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(db_index=True, max_length=200, verbose_name='ascii name')),
                ('slug', models.CharField(max_length=200, unique=True)),
                ('code', models.CharField(db_index=True, max_length=2, unique=True)),
            ],
            options={
                'abstract': False,
                'swappable': swapper.swappable_setting('cities', 'Continent'),
            },
        ),
        migrations.AddField(
            model_name='continent',
            name='alt_names',
            field=models.ManyToManyField(related_name='cities_continents', to='cities.AlternativeName'),
        ),
        migrations.RenameField(
            model_name='country',
            old_name='continent',
            new_name='continent_code',
        ),
        migrations.AddField(
            model_name='country',
            name='continent',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='countries', to=swapper.get_model_name('cities', 'Continent')),
        ),
        migrations.RunPython(add_continents, rm_continents),
        migrations.RunPython(add_continent_fks, rm_continent_fks),
        migrations.RemoveField(
            model_name='country',
            name='continent_code',
        ),
    ]
コード例 #11
0
class Migration(migrations.Migration):
    initial = True

    dependencies = [
        swapper.dependency('dataframe_store', 'Label'),
    ]

    operations = [
        migrations.CreateModel(
            name='Label',
            fields=[
                ('id', models.CharField(max_length=255, primary_key=True, serialize=False)),
            ],
            options={
                'verbose_name_plural': 'labels',
                'verbose_name': 'label',
                'abstract': False,
                'app_label': 'dataframe_store',
                'swappable': swapper.swappable_setting('dataframe_store', 'Label')
            },
        ),
    ]
コード例 #12
0
class Migration(migrations.Migration):

    dependencies = [
        ('openwisp_users', '0007_unique_email'),
        ('sample_notifications', '0001_initial'),
        swapper.dependency('openwisp_users', 'Organization'),
    ]

    operations = [
        migrations.CreateModel(
            name='TestApp',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                ('name', models.CharField(max_length=50)),
                (
                    'organization',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=swapper.get_model_name('openwisp_users',
                                                  'Organization'),
                    ),
                ),
            ],
            options={
                'verbose_name': 'Test App',
                'verbose_name_plural': 'Test App'
            },
        ),
    ]
コード例 #13
0
class Migration(migrations.Migration):

    dependencies = [
        ("django_input_collection", "0006_auto_20190122_2117"),
        swapper.dependency("django_input_collection", "BoundSuggestedResponse"),
    ]

    operations = [
        migrations.AddField(
            model_name="collectioninstrument",
            name="suggested_responses_new",
            field=models.ManyToManyField(
                blank=True,
                related_name="collectioninstrument_new",
                through=INPUT_BOUNDSUGGESTEDRESPONSE_MODEL,
                to="django_input_collection.SuggestedResponse",
            ),
        ),
        migrations.RemoveField(
            model_name="collectioninstrument",
            name="suggested_responses",
        ),
        migrations.RenameField(
            model_name="collectioninstrument",
            old_name="suggested_responses_new",
            new_name="suggested_responses",
        ),
        migrations.AlterField(
            model_name="collectioninstrument",
            name="suggested_responses",
            field=models.ManyToManyField(
                blank=True,
                through=INPUT_BOUNDSUGGESTEDRESPONSE_MODEL,
                to="django_input_collection.SuggestedResponse",
            ),
        ),
    ]
コード例 #14
0
class Migration(migrations.Migration):

    dependencies = [
        ('cities', '0005_add_foreignkeys_to_postalcode'),
        swapper.dependency('cities', 'City'),
    ]

    operations = [
        migrations.AddField(
            model_name='alternativename',
            name='is_historic',
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name='alternativename',
            name='kind',
            field=models.CharField(choices=ALTERNATIVE_NAME_TYPES,
                                   default='name',
                                   max_length=4),
        ),
        migrations.AlterField(
            model_name='alternativename',
            name='name',
            field=models.CharField(max_length=255),
        ),
        migrations.AlterField(
            model_name='postalcode',
            name='city',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name='postal_codes',
                to=swapper.get_model_name('cities', 'City')),
        ),
    ]
コード例 #15
0
class Migration(migrations.Migration):

    dependencies = [
        ('cms', '__first__'),
        swapper.dependency('imagestore', 'Album'),
    ]

    operations = [
        migrations.CreateModel(
            name='ImagestoreAlbumCarousel',
            fields=[
                ('cmsplugin_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin')),
                ('skin', models.CharField(default='jcarousel-skin-tango', max_length=100, verbose_name='Skin')),
                ('limit', models.IntegerField(null=True, verbose_name='Image limit', blank=True)),
                ('size', models.CharField(default='72x72', max_length=20, verbose_name='Thumbnail size')),
                ('full_size', models.CharField(default='600x600', max_length=20, verbose_name='Full size view')),
                ('template_file', models.CharField(default='cms/plugins/imagestore_album_carousel.html', max_length=100, null=True, verbose_name='Template file', blank=True)),
                ('album', models.ForeignKey(verbose_name='Album', to=swapper.get_model_name('imagestore', 'Album'))),
            ],
            options={
                'abstract': False,
            },
            bases=('cms.cmsplugin',),
        ),
        migrations.CreateModel(
            name='ImagestoreAlbumPtr',
            fields=[
                ('cmsplugin_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='cms.CMSPlugin')),
                ('album', models.ForeignKey(verbose_name='Album', to=swapper.get_model_name('imagestore', 'Album'))),
            ],
            options={
                'abstract': False,
            },
            bases=('cms.cmsplugin',),
        ),
    ]
コード例 #16
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('contenttypes', '0002_remove_content_type_name'),
        ('sample_pki', '0002_default_group_permissions'),
        swapper.dependency('openwisp_users', 'Organization'),
    ]

    operations = [
        migrations.CreateModel(
            name='Config',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                (
                    'backend',
                    models.CharField(
                        choices=[
                            ('netjsonconfig.OpenWrt', 'OpenWRT'),
                            ('netjsonconfig.OpenWisp',
                             'OpenWISP Firmware 1.x'),
                        ],
                        help_text=
                        ('Select <a href="http://netjsonconfig.openwisp.org'
                         '/en/stable/" target="_blank">netjsonconfig</a> backend'
                         ),
                        max_length=128,
                        verbose_name='backend',
                    ),
                ),
                (
                    'config',
                    jsonfield.fields.JSONField(
                        blank=True,
                        default=dict,
                        dump_kwargs={
                            'ensure_ascii': False,
                            'indent': 4
                        },
                        help_text=
                        'configuration in NetJSON DeviceConfiguration format',
                        load_kwargs={
                            'object_pairs_hook': collections.OrderedDict
                        },
                        verbose_name='configuration',
                    ),
                ),
                (
                    'status',
                    model_utils.fields.StatusField(
                        choices=[
                            ('modified', 'modified'),
                            ('applied', 'applied'),
                            ('error', 'error'),
                        ],
                        default='modified',
                        help_text=
                        ('"modified" means the configuration is not applied yet; '
                         '\n"applied" means the configuration is applied '
                         'successfully; \n"error" means the configuration '
                         'caused issues and it was rolled back;'),
                        max_length=100,
                        no_check_for_status=True,
                        verbose_name='configuration status',
                    ),
                ),
                (
                    'context',
                    jsonfield.fields.JSONField(
                        blank=True,
                        default=dict,
                        dump_kwargs={
                            'ensure_ascii': False,
                            'indent': 4
                        },
                        help_text=
                        ('Additional <a href="http://netjsonconfig.openwisp.org'
                         '/en/stable/general/basics.html#context" target="_blank">'
                         'context (configuration variables)</a> in JSON format'
                         ),
                        load_kwargs={
                            'object_pairs_hook': collections.OrderedDict
                        },
                    ),
                ),
                ('details',
                 models.CharField(blank=True, max_length=64, null=True)),
            ],
            options={
                'verbose_name': 'configuration',
                'verbose_name_plural': 'configurations',
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='TaggedTemplate',
            fields=[
                (
                    'id',
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name='ID',
                    ),
                ),
                (
                    'object_id',
                    models.UUIDField(db_index=True, verbose_name='object ID'),
                ),
                ('details',
                 models.CharField(blank=True, max_length=64, null=True)),
                (
                    'content_type',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name=
                        'sample_config_taggedtemplate_tagged_items',
                        to='contenttypes.ContentType',
                        verbose_name='content type',
                    ),
                ),
            ],
            options={
                'verbose_name': 'Tagged item',
                'verbose_name_plural': 'Tags',
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='TemplateTag',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'name',
                    models.CharField(max_length=100,
                                     unique=True,
                                     verbose_name='name'),
                ),
                (
                    'slug',
                    models.SlugField(max_length=100,
                                     unique=True,
                                     verbose_name='slug'),
                ),
                ('details',
                 models.CharField(blank=True, max_length=64, null=True)),
            ],
            options={
                'verbose_name': 'Tag',
                'verbose_name_plural': 'Tags',
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Vpn',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                ('name',
                 models.CharField(db_index=True, max_length=64, unique=True)),
                (
                    'config',
                    jsonfield.fields.JSONField(
                        default=dict,
                        dump_kwargs={
                            'ensure_ascii': False,
                            'indent': 4
                        },
                        help_text=
                        'configuration in NetJSON DeviceConfiguration format',
                        load_kwargs={
                            'object_pairs_hook': collections.OrderedDict
                        },
                        verbose_name='configuration',
                    ),
                ),
                (
                    'host',
                    models.CharField(
                        help_text='VPN server hostname or ip address',
                        max_length=64),
                ),
                (
                    'key',
                    openwisp_utils.base.KeyField(
                        db_index=True,
                        default=openwisp_utils.utils.get_random_key,
                        help_text=None,
                        max_length=64,
                        validators=[
                            django.core.validators.RegexValidator(
                                re.compile('^[^\\s/\\.]+$'),
                                code='invalid',
                                message=('This value must not contain spaces, '
                                         'dots or slashes.'),
                            )
                        ],
                    ),
                ),
                (
                    'backend',
                    models.CharField(
                        choices=[('openwisp_controller.vpn_backends.OpenVpn',
                                  'OpenVPN')],
                        help_text='Select VPN configuration backend',
                        max_length=128,
                        verbose_name='VPN backend',
                    ),
                ),
                ('notes', models.TextField(blank=True)),
                ('dh', models.TextField(blank=True)),
                ('details',
                 models.CharField(blank=True, max_length=64, null=True)),
                (
                    'ca',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to='sample_pki.Ca',
                        verbose_name='Certification Authority',
                    ),
                ),
                (
                    'cert',
                    models.ForeignKey(
                        blank=True,
                        help_text='leave blank to create automatically',
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to='sample_pki.Cert',
                        verbose_name='x509 Certificate',
                    ),
                ),
                (
                    'organization',
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to=swapper.get_model_name('openwisp_users',
                                                  'Organization'),
                        verbose_name='organization',
                    ),
                ),
            ],
            options={
                'verbose_name': 'VPN server',
                'verbose_name_plural': 'VPN servers',
                'abstract': False,
            },
            bases=(openwisp_users.mixins.ValidateOrgMixin, models.Model),
        ),
        migrations.CreateModel(
            name='VpnClient',
            fields=[
                (
                    'id',
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name='ID',
                    ),
                ),
                ('auto_cert', models.BooleanField(default=False)),
                ('details',
                 models.CharField(blank=True, max_length=64, null=True)),
                (
                    'cert',
                    models.OneToOneField(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to='sample_pki.Cert',
                    ),
                ),
                (
                    'config',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to='sample_config.Config',
                    ),
                ),
                (
                    'vpn',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to='sample_config.Vpn',
                    ),
                ),
            ],
            options={
                'verbose_name': 'VPN client',
                'verbose_name_plural': 'VPN clients',
                'abstract': False,
                'unique_together': {('config', 'vpn')},
            },
        ),
        migrations.CreateModel(
            name='Template',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                ('name',
                 models.CharField(db_index=True, max_length=64, unique=True)),
                (
                    'backend',
                    models.CharField(
                        choices=[
                            ('netjsonconfig.OpenWrt', 'OpenWRT'),
                            ('netjsonconfig.OpenWisp',
                             'OpenWISP Firmware 1.x'),
                        ],
                        help_text=
                        ('Select <a href="http://netjsonconfig.openwisp.org'
                         '/en/stable/" target="_blank">netjsonconfig</a> backend'
                         ),
                        max_length=128,
                        verbose_name='backend',
                    ),
                ),
                (
                    'config',
                    jsonfield.fields.JSONField(
                        blank=True,
                        default=dict,
                        dump_kwargs={
                            'ensure_ascii': False,
                            'indent': 4
                        },
                        help_text=
                        'configuration in NetJSON DeviceConfiguration format',
                        load_kwargs={
                            'object_pairs_hook': collections.OrderedDict
                        },
                        verbose_name='configuration',
                    ),
                ),
                (
                    'type',
                    models.CharField(
                        choices=[('generic', 'Generic'),
                                 ('vpn', 'VPN-client')],
                        db_index=True,
                        default='generic',
                        help_text=
                        ('template type, determines which features are available'
                         ),
                        max_length=16,
                        verbose_name='type',
                    ),
                ),
                (
                    'default',
                    models.BooleanField(
                        db_index=True,
                        default=False,
                        help_text=('whether new configurations will have '
                                   'this template enabled by default'),
                        verbose_name='enabled by default',
                    ),
                ),
                (
                    'required',
                    models.BooleanField(
                        db_index=True,
                        default=False,
                        help_text=
                        ('if checked, will force the assignment of this template to '
                         'all the devices of the organization (if no organization '
                         'is selected, it will be required for every device '
                         'in the system)'),
                        verbose_name='required',
                    ),
                ),
                (
                    'auto_cert',
                    models.BooleanField(
                        db_index=True,
                        default=(openwisp_controller.config.base.template.
                                 default_auto_cert),
                        help_text=
                        ('whether x509 client certificates should be automatically '
                         'managed behind the scenes for each configuration using '
                         'this template, valid only for the VPN type'),
                        verbose_name='auto certificate',
                    ),
                ),
                (
                    'default_values',
                    jsonfield.fields.JSONField(
                        blank=True,
                        default=dict,
                        dump_kwargs={
                            'ensure_ascii': False,
                            'indent': 4
                        },
                        help_text=
                        ('A dictionary containing the default values for '
                         'the variables used by this template; these default '
                         'variables will be used during schema validation.'),
                        load_kwargs={
                            'object_pairs_hook': collections.OrderedDict
                        },
                        verbose_name='Default Values',
                    ),
                ),
                ('details',
                 models.CharField(blank=True, max_length=64, null=True)),
                (
                    'organization',
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to=swapper.get_model_name('openwisp_users',
                                                  'Organization'),
                        verbose_name='organization',
                    ),
                ),
                (
                    'tags',
                    taggit.managers.TaggableManager(
                        blank=True,
                        help_text=(
                            'A comma-separated list of template tags, may '
                            'be used to ease auto configuration with specific '
                            'settings (eg: 4G, mesh, WDS, VPN, ecc.)'),
                        through='sample_config.TaggedTemplate',
                        to='sample_config.TemplateTag',
                        verbose_name='Tags',
                    ),
                ),
                (
                    'vpn',
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to='sample_config.Vpn',
                        verbose_name='VPN',
                    ),
                ),
            ],
            options={
                'verbose_name': 'template',
                'verbose_name_plural': 'templates',
                'abstract': False,
                'unique_together': {('organization', 'name')},
            },
            bases=(openwisp_users.mixins.ValidateOrgMixin, models.Model),
        ),
        migrations.AddField(
            model_name='taggedtemplate',
            name='tag',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name='sample_config_taggedtemplate_items',
                to='sample_config.TemplateTag',
            ),
        ),
        migrations.CreateModel(
            name='OrganizationConfigSettings',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'registration_enabled',
                    models.BooleanField(
                        default=True,
                        help_text=('Whether automatic registration of devices '
                                   'is enabled or not'),
                        verbose_name='auto-registration enabled',
                    ),
                ),
                (
                    'shared_secret',
                    openwisp_utils.base.KeyField(
                        db_index=True,
                        default=openwisp_utils.utils.get_random_key,
                        help_text='used for automatic registration of devices',
                        max_length=32,
                        unique=True,
                        validators=[
                            django.core.validators.RegexValidator(
                                re.compile('^[^\\s/\\.]+$'),
                                code='invalid',
                                message=('This value must not contain spaces, '
                                         'dots or slashes.'),
                            )
                        ],
                        verbose_name='shared secret',
                    ),
                ),
                ('details',
                 models.CharField(blank=True, max_length=64, null=True)),
                (
                    'organization',
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name='config_settings',
                        to=swapper.get_model_name('openwisp_users',
                                                  'Organization'),
                        verbose_name='organization',
                    ),
                ),
            ],
            options={
                'verbose_name': 'Configuration management settings',
                'verbose_name_plural': 'Configuration management settings',
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Device',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                (
                    'name',
                    models.CharField(
                        db_index=True,
                        max_length=64,
                        validators=[
                            django.core.validators.RegexValidator(
                                re.compile(
                                    '^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}'
                                    '[a-zA-Z0-9])(\\.([a-zA-Z0-9]|[a-zA-Z0-9]'
                                    '[a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9]))*$|^'
                                    '([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$'
                                ),
                                code='invalid',
                                message=
                                ('Must be either a valid hostname or mac address.'
                                 ),
                            )
                        ],
                        help_text=(
                            'must be either a valid hostname or mac address'),
                    ),
                ),
                (
                    'mac_address',
                    models.CharField(
                        db_index=True,
                        help_text='primary mac address',
                        max_length=17,
                        validators=[
                            django.core.validators.RegexValidator(
                                re.compile(
                                    '^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$'
                                ),
                                code='invalid',
                                message='Must be a valid mac address.',
                            )
                        ],
                    ),
                ),
                (
                    'key',
                    openwisp_utils.base.KeyField(
                        blank=True,
                        db_index=True,
                        default=None,
                        help_text='unique device key',
                        max_length=64,
                        unique=True,
                        validators=[
                            django.core.validators.RegexValidator(
                                re.compile('^[^\\s/\\.]+$'),
                                code='invalid',
                                message=('This value must not contain spaces, '
                                         'dots or slashes.'),
                            )
                        ],
                    ),
                ),
                (
                    'model',
                    models.CharField(
                        blank=True,
                        db_index=True,
                        help_text='device model and manufacturer',
                        max_length=64,
                    ),
                ),
                (
                    'os',
                    models.CharField(
                        blank=True,
                        db_index=True,
                        help_text='operating system identifier',
                        max_length=128,
                        verbose_name='operating system',
                    ),
                ),
                (
                    'system',
                    models.CharField(
                        blank=True,
                        db_index=True,
                        help_text='system on chip or CPU info',
                        max_length=128,
                        verbose_name='SOC / CPU',
                    ),
                ),
                ('notes',
                 models.TextField(blank=True, help_text='internal notes')),
                (
                    'last_ip',
                    models.GenericIPAddressField(
                        blank=True,
                        db_index=True,
                        help_text=(
                            'indicates the IP address logged from the last '
                            'request coming from the device'),
                        null=True,
                    ),
                ),
                (
                    'management_ip',
                    models.GenericIPAddressField(
                        blank=True,
                        db_index=True,
                        help_text=
                        ('ip address of the management interface, if available'
                         ),
                        null=True,
                    ),
                ),
                (
                    'hardware_id',
                    models.CharField(
                        blank=True,
                        help_text='Serial number of this device',
                        max_length=32,
                        null=True,
                        verbose_name='Serial number',
                    ),
                ),
                ('details',
                 models.CharField(blank=True, max_length=64, null=True)),
                (
                    'organization',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=swapper.get_model_name('openwisp_users',
                                                  'Organization'),
                        verbose_name='organization',
                    ),
                ),
            ],
            options={
                'abstract': False,
                'unique_together': {
                    ('mac_address', 'organization'),
                    ('hardware_id', 'organization'),
                    ('name', 'organization'),
                },
                'verbose_name': app_settings.DEVICE_VERBOSE_NAME[0],
                'verbose_name_plural': app_settings.DEVICE_VERBOSE_NAME[1],
            },
            bases=(openwisp_users.mixins.ValidateOrgMixin, models.Model),
        ),
        migrations.AddField(
            model_name='config',
            name='device',
            field=models.OneToOneField(
                on_delete=django.db.models.deletion.CASCADE,
                to='sample_config.Device'),
        ),
        migrations.AddField(
            model_name='config',
            name='templates',
            field=openwisp_controller.config.sortedm2m.fields.
            SortedManyToManyField(
                blank=True,
                help_text='configuration templates, applied from first to last',
                related_name='config_relations',
                to='sample_config.Template',
                verbose_name='templates',
            ),
        ),
        migrations.AddField(
            model_name='config',
            name='vpn',
            field=models.ManyToManyField(
                blank=True,
                related_name='vpn_relations',
                through='sample_config.VpnClient',
                to='sample_config.Vpn',
            ),
        ),
    ]
コード例 #17
0
class Migration(migrations.Migration):

    replaces = [('check', '0001_initial'),
                ('check', '0002_check_unique_together')]

    dependencies = [
        ('check', '__first__'),
        ('contenttypes', '0002_remove_content_type_name'),
        swapper.dependency('check', 'Check'),
    ]

    operations = [
        migrations.CreateModel(
            name='Check',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                ('name', models.CharField(db_index=True, max_length=64)),
                ('active', models.BooleanField(db_index=True, default=True)),
                ('description', models.TextField(blank=True,
                                                 help_text='Notes')),
                (
                    'object_id',
                    models.CharField(blank=True, db_index=True, max_length=36),
                ),
                (
                    'check',
                    models.CharField(
                        choices=CHECK_CLASSES,
                        db_index=True,
                        help_text='Select check type',
                        max_length=128,
                        verbose_name='check type',
                    ),
                ),
                (
                    'params',
                    jsonfield.fields.JSONField(
                        blank=True,
                        default=dict,
                        dump_kwargs={'indent': 4},
                        help_text='parameters needed to perform the check',
                        load_kwargs={
                            'object_pairs_hook': collections.OrderedDict
                        },
                        verbose_name='parameters',
                    ),
                ),
                (
                    'content_type',
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to='contenttypes.contenttype',
                    ),
                ),
            ],
            options={
                'abstract': False,
                'swappable': swapper.swappable_setting('check', 'Check'),
                'unique_together': {('name', 'object_id', 'content_type')},
            },
        )
    ]
コード例 #18
0
ファイル: 0001_initial.py プロジェクト: varisbhalala/test
class Migration(migrations.Migration):

    dependencies = [
        swapper.dependency('cities', 'City'),
        swapper.dependency('cities', 'Country'),
    ]

    operations = [
        migrations.CreateModel(
            name='AlternativeName',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('name', models.CharField(max_length=256)),
                ('language', models.CharField(max_length=100)),
                ('is_preferred', models.BooleanField(default=False)),
                ('is_short', models.BooleanField(default=False)),
                ('is_colloquial', models.BooleanField(default=False)),
            ],
        ),
        migrations.CreateModel(
            name='City',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('name',
                 models.CharField(max_length=200,
                                  verbose_name='ascii name',
                                  db_index=True)),
                ('slug', models.CharField(max_length=200)),
                ('name_std',
                 models.CharField(max_length=200,
                                  verbose_name='standard name',
                                  db_index=True)),
                ('location',
                 django.contrib.gis.db.models.fields.PointField(srid=4326)),
                ('population', models.IntegerField()),
                ('elevation', models.IntegerField(null=True)),
                ('kind', models.CharField(max_length=10)),
                ('timezone', models.CharField(max_length=40)),
                ('alt_names',
                 models.ManyToManyField(to='cities.AlternativeName')),
            ],
            options={
                'swappable': swapper.swappable_setting('cities', 'City'),
                'verbose_name_plural': 'cities',
            },
        ),
        migrations.CreateModel(
            name='Country',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('name',
                 models.CharField(max_length=200,
                                  verbose_name='ascii name',
                                  db_index=True)),
                ('slug', models.CharField(max_length=200)),
                ('code', models.CharField(max_length=2, db_index=True)),
                ('code3', models.CharField(max_length=3, db_index=True)),
                ('population', models.IntegerField()),
                ('area', models.IntegerField(null=True)),
                ('currency', models.CharField(max_length=3, null=True)),
                ('currency_name', models.CharField(max_length=50, null=True)),
                ('languages', models.CharField(max_length=250, null=True)),
                ('phone', models.CharField(max_length=20)),
                ('continent', models.CharField(max_length=2)),
                ('tld', models.CharField(max_length=5)),
                ('capital', models.CharField(max_length=100)),
                ('alt_names',
                 models.ManyToManyField(to='cities.AlternativeName')),
                ('neighbours',
                 models.ManyToManyField(related_name='neighbours_rel_+',
                                        to=swapper.get_model_name(
                                            'cities', 'Country'))),
            ],
            options={
                'ordering': ['name'],
                'swappable': swapper.swappable_setting('cities', 'Country'),
                'verbose_name_plural': 'countries',
            },
        ),
        migrations.CreateModel(
            name='District',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('name',
                 models.CharField(max_length=200,
                                  verbose_name='ascii name',
                                  db_index=True)),
                ('slug', models.CharField(max_length=200)),
                ('name_std',
                 models.CharField(max_length=200,
                                  verbose_name='standard name',
                                  db_index=True)),
                ('location',
                 django.contrib.gis.db.models.fields.PointField(srid=4326)),
                ('population', models.IntegerField()),
                ('alt_names',
                 models.ManyToManyField(to='cities.AlternativeName')),
                ('city',
                 models.ForeignKey(to=swapper.get_model_name('cities', 'City'),
                                   on_delete=SET_NULL_OR_CASCADE)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='PostalCode',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('name',
                 models.CharField(max_length=200,
                                  verbose_name='ascii name',
                                  db_index=True)),
                ('slug', models.CharField(max_length=200)),
                ('code', models.CharField(max_length=20)),
                ('location',
                 django.contrib.gis.db.models.fields.PointField(srid=4326)),
                ('region_name', models.CharField(max_length=100,
                                                 db_index=True)),
                ('subregion_name',
                 models.CharField(max_length=100, db_index=True)),
                ('district_name',
                 models.CharField(max_length=100, db_index=True)),
                ('alt_names',
                 models.ManyToManyField(to='cities.AlternativeName')),
                ('country',
                 models.ForeignKey(related_name='postal_codes',
                                   to=swapper.get_model_name(
                                       'cities', 'Country'),
                                   on_delete=SET_NULL_OR_CASCADE)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Region',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('name',
                 models.CharField(max_length=200,
                                  verbose_name='ascii name',
                                  db_index=True)),
                ('slug', models.CharField(max_length=200)),
                ('name_std',
                 models.CharField(max_length=200,
                                  verbose_name='standard name',
                                  db_index=True)),
                ('code', models.CharField(max_length=200, db_index=True)),
                ('alt_names',
                 models.ManyToManyField(to='cities.AlternativeName')),
                ('country',
                 models.ForeignKey(to=swapper.get_model_name(
                     'cities', 'Country'),
                                   on_delete=SET_NULL_OR_CASCADE)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Subregion',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('name',
                 models.CharField(max_length=200,
                                  verbose_name='ascii name',
                                  db_index=True)),
                ('slug', models.CharField(max_length=200)),
                ('name_std',
                 models.CharField(max_length=200,
                                  verbose_name='standard name',
                                  db_index=True)),
                ('code', models.CharField(max_length=200, db_index=True)),
                ('alt_names',
                 models.ManyToManyField(to='cities.AlternativeName')),
                ('region',
                 models.ForeignKey(to='cities.Region',
                                   on_delete=SET_NULL_OR_CASCADE)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.AddField(
            model_name='city',
            name='country',
            field=models.ForeignKey(to=swapper.get_model_name(
                'cities', 'Country'),
                                    on_delete=SET_NULL_OR_CASCADE),
        ),
        migrations.AddField(
            model_name='city',
            name='region',
            field=models.ForeignKey(blank=True,
                                    to='cities.Region',
                                    null=True,
                                    on_delete=SET_NULL_OR_CASCADE),
        ),
        migrations.AddField(
            model_name='city',
            name='subregion',
            field=models.ForeignKey(blank=True,
                                    to='cities.Subregion',
                                    null=True,
                                    on_delete=SET_NULL_OR_CASCADE),
        ),
    ]
コード例 #19
0
class Migration(migrations.Migration):
    """
    Initial migration for openwisp-radius models
    Note (It's Manually Edited):
    - settings._OPENWISP_DEFAULT_ORG_UUID must be set before
      running; as done in 'openwisp_users'->'0003_default_organization'
    - Custom logic for setting default organization in all existing
      relevent records (read comments)
    """

    dependencies = [
        swapper.dependency(*swapper.split(settings.AUTH_USER_MODEL),
                           version='0004_default_groups'),
        ('openwisp_radius', '0001_initial_freeradius'),
    ]

    operations = [
        migrations.CreateModel(
            name='RadiusBatch',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                (
                    'strategy',
                    models.CharField(
                        choices=[
                            ('prefix', 'Generate from prefix'),
                            ('csv', 'Import from CSV'),
                        ],
                        db_index=True,
                        help_text=
                        'Import users from a CSV or generate using a prefix',
                        max_length=16,
                        verbose_name='strategy',
                    ),
                ),
                (
                    'csvfile',
                    models.FileField(
                        blank=True,
                        help_text=
                        ('The csv file containing the user details to be uploaded'
                         ),
                        null=True,
                        upload_to="",
                        verbose_name='CSV',
                    ),
                ),
                (
                    'prefix',
                    models.CharField(
                        blank=True,
                        help_text=
                        ('Usernames generated will be of the format [prefix][number]'
                         ),
                        max_length=20,
                        null=True,
                        verbose_name='prefix',
                    ),
                ),
                (
                    'pdf',
                    models.FileField(
                        blank=True,
                        help_text=
                        ('The pdf file containing list of usernames and passwords'
                         ),
                        null=True,
                        upload_to="",
                        verbose_name='PDF',
                    ),
                ),
                (
                    'expiration_date',
                    models.DateField(
                        blank=True,
                        help_text='If left blank users will never expire',
                        null=True,
                        verbose_name='expiration date',
                    ),
                ),
                (
                    'name',
                    models.CharField(
                        db_index=True,
                        help_text='A unique batch name',
                        max_length=128,
                        verbose_name='name',
                    ),
                ),
                (
                    'organization',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=get_model_name('openwisp_users', 'Organization'),
                        verbose_name='organization',
                    ),
                ),
                (
                    'users',
                    models.ManyToManyField(
                        blank=True,
                        help_text='List of users uploaded in this batch',
                        related_name='radius_batch',
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                'verbose_name': 'batch user creation',
                'verbose_name_plural': 'batch user creation operations',
                'db_table': 'radbatch',
                'abstract': False,
                'swappable': 'OPENWISP_RADIUS_RADIUSBATCH_MODEL',
            },
            bases=(openwisp_users.mixins.ValidateOrgMixin, models.Model),
        ),
        migrations.CreateModel(
            name='RadiusGroup',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                (
                    'name',
                    models.CharField(
                        db_index=True,
                        max_length=255,
                        unique=True,
                        verbose_name='group name',
                    ),
                ),
                (
                    'description',
                    models.CharField(blank=True,
                                     max_length=64,
                                     null=True,
                                     verbose_name='description'),
                ),
                (
                    'default',
                    models.BooleanField(
                        default=False,
                        help_text=(
                            'The default group is automatically assigned '
                            'to new users; changing the default group has only '
                            'effect on new users (existing users will keep '
                            'being members of their current group)'),
                        verbose_name='is default?',
                    ),
                ),
                (
                    'organization',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=get_model_name('openwisp_users', 'Organization'),
                        verbose_name='organization',
                    ),
                ),
            ],
            options={
                'verbose_name': 'group',
                'verbose_name_plural': 'groups',
                'abstract': False,
                'swappable': 'OPENWISP_RADIUS_RADIUSGROUP_MODEL',
            },
            bases=(openwisp_users.mixins.ValidateOrgMixin, models.Model),
        ),
        migrations.CreateModel(
            name='OrganizationRadiusSettings',
            fields=[
                (
                    'id',
                    models.UUIDField(default=uuid.uuid4,
                                     primary_key=True,
                                     serialize=False),
                ),
                (
                    'token',
                    openwisp_utils.base.KeyField(
                        default=openwisp_utils.utils.get_random_key,
                        help_text=None,
                        max_length=32,
                        validators=[
                            django.core.validators.RegexValidator(
                                re.compile('^[^\\s/\\.]+$'),
                                code='invalid',
                                message=('This value must not contain spaces, '
                                         'dots or slashes.'),
                            )
                        ],
                    ),
                ),
                (
                    'organization',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=get_model_name('openwisp_users', 'Organization'),
                        verbose_name='organization',
                    ),
                ),
            ],
            options={'abstract': False},
            bases=(openwisp_users.mixins.ValidateOrgMixin, models.Model),
        ),
        migrations.AddField(
            model_name='radiuscheck',
            name='is_active',
            field=models.BooleanField(default=True),
        ),
        migrations.AddField(
            model_name='radiuscheck',
            name='notes',
            field=models.TextField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='radiuscheck',
            name='user',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AddField(
            model_name='radiuscheck',
            name='valid_until',
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='radiusgroupcheck',
            name='group',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to=settings.OPENWISP_RADIUS_RADIUSGROUP_MODEL,
            ),
        ),
        migrations.AddField(
            model_name='radiusgroupreply',
            name='group',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to=settings.OPENWISP_RADIUS_RADIUSGROUP_MODEL,
            ),
        ),
        migrations.AddField(
            model_name='radiusreply',
            name='user',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AddField(
            model_name='radiususergroup',
            name='group',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to=settings.OPENWISP_RADIUS_RADIUSGROUP_MODEL,
            ),
        ),
        migrations.AddField(
            model_name='radiususergroup',
            name='user',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AlterField(
            model_name='radiusaccounting',
            name='called_station_id',
            field=models.CharField(
                blank=True,
                db_column='calledstationid',
                db_index=True,
                max_length=50,
                null=True,
                verbose_name='called station ID',
            ),
        ),
        migrations.AlterField(
            model_name='radiusaccounting',
            name='calling_station_id',
            field=models.CharField(
                blank=True,
                db_column='callingstationid',
                db_index=True,
                max_length=50,
                null=True,
                verbose_name='calling station ID',
            ),
        ),
        migrations.AlterField(
            model_name='radiuscheck',
            name='username',
            field=models.CharField(blank=True,
                                   db_index=True,
                                   max_length=64,
                                   verbose_name='username'),
        ),
        migrations.AlterField(
            model_name='radiusgroupcheck',
            name='groupname',
            field=models.CharField(blank=True,
                                   db_index=True,
                                   max_length=64,
                                   verbose_name='group name'),
        ),
        migrations.AlterField(
            model_name='radiusgroupreply',
            name='groupname',
            field=models.CharField(blank=True,
                                   db_index=True,
                                   max_length=64,
                                   verbose_name='group name'),
        ),
        migrations.AlterField(
            model_name='radiusreply',
            name='username',
            field=models.CharField(blank=True,
                                   db_index=True,
                                   max_length=64,
                                   verbose_name='username'),
        ),
        migrations.AlterField(
            model_name='radiususergroup',
            name='groupname',
            field=models.CharField(blank=True,
                                   max_length=64,
                                   verbose_name='group name'),
        ),
        migrations.AlterField(
            model_name='radiususergroup',
            name='username',
            field=models.CharField(blank=True,
                                   db_index=True,
                                   max_length=64,
                                   verbose_name='username'),
        ),
        migrations.AlterUniqueTogether(name='radiusbatch',
                                       unique_together={('name',
                                                         'organization')}),
        migrations.AlterModelOptions(
            name='organizationradiussettings',
            options={
                'verbose_name': 'Organization radius settings',
                'verbose_name_plural': 'Organization radius settings',
            },
        ),
        migrations.AlterField(
            model_name='organizationradiussettings',
            name='id',
            field=models.UUIDField(default=uuid.uuid4,
                                   editable=False,
                                   primary_key=True,
                                   serialize=False),
        ),
        migrations.AlterField(
            model_name='organizationradiussettings',
            name='organization',
            field=models.OneToOneField(
                on_delete=django.db.models.deletion.CASCADE,
                related_name='radius_settings',
                to=get_model_name('openwisp_users', 'Organization'),
                verbose_name='organization',
            ),
        ),
        # Set null=True for organization field to allow
        # creation without giving a default value
        migrations.AddField(
            model_name='nas',
            name='organization',
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to=get_model_name('openwisp_users', 'Organization'),
                verbose_name='organization',
            ),
        ),
        migrations.AddField(
            model_name='radiusaccounting',
            name='organization',
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to=get_model_name('openwisp_users', 'Organization'),
                verbose_name='organization',
            ),
        ),
        migrations.AddField(
            model_name='radiuscheck',
            name='organization',
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to=get_model_name('openwisp_users', 'Organization'),
                verbose_name='organization',
            ),
        ),
        migrations.AddField(
            model_name='radiuspostauth',
            name='organization',
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to=get_model_name('openwisp_users', 'Organization'),
                verbose_name='organization',
            ),
        ),
        migrations.AddField(
            model_name='radiusreply',
            name='organization',
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to=get_model_name('openwisp_users', 'Organization'),
                verbose_name='organization',
            ),
        ),
        # Set default organization for all the existing records
        migrations.RunPython(add_default_organization,
                             reverse_code=migrations.RunPython.noop),
        # Set null=False for all organization fields that need
        # NOT NULL condition as per the openwisp-radius model
        migrations.AlterField(
            model_name='nas',
            name='organization',
            field=models.ForeignKey(
                null=False,
                blank=False,
                on_delete=django.db.models.deletion.CASCADE,
                to=get_model_name('openwisp_users', 'Organization'),
                verbose_name='organization',
            ),
        ),
        migrations.AlterField(
            model_name='radiusaccounting',
            name='organization',
            field=models.ForeignKey(
                null=False,
                blank=False,
                on_delete=django.db.models.deletion.CASCADE,
                to=get_model_name('openwisp_users', 'Organization'),
                verbose_name='organization',
            ),
        ),
        migrations.AlterField(
            model_name='radiuscheck',
            name='organization',
            field=models.ForeignKey(
                null=False,
                blank=False,
                on_delete=django.db.models.deletion.CASCADE,
                to=get_model_name('openwisp_users', 'Organization'),
                verbose_name='organization',
            ),
        ),
        migrations.AlterField(
            model_name='radiuspostauth',
            name='organization',
            field=models.ForeignKey(
                null=False,
                blank=False,
                on_delete=django.db.models.deletion.CASCADE,
                to=get_model_name('openwisp_users', 'Organization'),
                verbose_name='organization',
            ),
        ),
        migrations.AlterField(
            model_name='radiusreply',
            name='organization',
            field=models.ForeignKey(
                null=False,
                blank=False,
                on_delete=django.db.models.deletion.CASCADE,
                to=get_model_name('openwisp_users', 'Organization'),
                verbose_name='organization',
            ),
        ),
    ]
コード例 #20
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('openwisp_users', '0009_create_organization_owners'),
        swapper.dependency('openwisp_users', 'Organization'),
    ]

    operations = [
        migrations.CreateModel(
            name='Notification',
            fields=[
                (
                    'level',
                    models.CharField(
                        choices=[
                            ('success', 'success'),
                            ('info', 'info'),
                            ('warning', 'warning'),
                            ('error', 'error'),
                        ],
                        default='info',
                        max_length=20,
                    ),
                ),
                ('unread', models.BooleanField(db_index=True, default=True)),
                ('actor_object_id', models.CharField(max_length=255)),
                ('verb', models.CharField(max_length=255)),
                ('description', models.TextField(blank=True, null=True)),
                (
                    'target_object_id',
                    models.CharField(blank=True, max_length=255, null=True),
                ),
                (
                    'action_object_object_id',
                    models.CharField(blank=True, max_length=255, null=True),
                ),
                (
                    'timestamp',
                    models.DateTimeField(db_index=True,
                                         default=django.utils.timezone.now),
                ),
                ('public', models.BooleanField(db_index=True, default=True)),
                ('deleted', models.BooleanField(db_index=True, default=False)),
                ('emailed', models.BooleanField(db_index=True, default=False)),
                ('data', jsonfield.fields.JSONField(blank=True, null=True)),
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'action_object_content_type',
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name='notify_action_object',
                        to='contenttypes.ContentType',
                    ),
                ),
                (
                    'actor_content_type',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name='notify_actor',
                        to='contenttypes.ContentType',
                    ),
                ),
                (
                    'recipient',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name='notifications',
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    'target_content_type',
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name='notify_target',
                        to='contenttypes.ContentType',
                    ),
                ),
                (
                    'type',
                    models.CharField(
                        choices=NOTIFICATION_CHOICES,
                        max_length=30,
                        null=True,
                    ),
                ),
                ('details',
                 models.CharField(blank=True, max_length=64, null=True)),
            ],
            options={
                'ordering': ('-timestamp', ),
                'abstract': False,
                'index_together': {('recipient', 'unread')},
            },
        ),
        migrations.CreateModel(
            name='NotificationSetting',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'type',
                    models.CharField(
                        choices=NOTIFICATION_CHOICES,
                        max_length=30,
                        null=True,
                        verbose_name='Notification Type',
                    ),
                ),
                (
                    'web',
                    models.BooleanField(
                        null=True,
                        blank=True,
                        help_text=
                        ('Note: Non-superadmin users receive notifications only '
                         'for organizations of which they are member of.'),
                        verbose_name='web notifications',
                    ),
                ),
                (
                    'email',
                    models.BooleanField(
                        null=True,
                        blank=True,
                        help_text=
                        ('Note: Non-superadmin users receive notifications only '
                         'for organizations of which they are member of.'),
                        verbose_name='email notifications',
                    ),
                ),
                ('details',
                 models.CharField(blank=True, max_length=64, null=True)),
                (
                    'organization',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=swapper.get_model_name('openwisp_users',
                                                  'Organization'),
                    ),
                ),
                (
                    'user',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                'verbose_name': 'user notification settings',
                'verbose_name_plural': 'user notification settings',
                'ordering': ['organization', 'type'],
                'abstract': False,
            },
        ),
        migrations.AddConstraint(
            model_name='notificationsetting',
            constraint=models.UniqueConstraint(
                fields=('organization', 'type', 'user'),
                name='unique_notification_setting',
            ),
        ),
        migrations.AddIndex(
            model_name='notificationsetting',
            index=models.Index(fields=['type', 'organization'],
                               name='sample_noti_type_b2cb70_idx'),
        ),
        migrations.CreateModel(
            name='IgnoreObjectNotification',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                ('object_id', models.CharField(max_length=255)),
                ('valid_till', models.DateTimeField(null=True)),
                ('details',
                 models.CharField(blank=True, max_length=64, null=True)),
                (
                    'object_content_type',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to='contenttypes.ContentType',
                    ),
                ),
                (
                    'user',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                'abstract': False,
                'ordering': ['valid_till']
            },
        ),
    ]
コード例 #21
0
class Migration(migrations.Migration):

    dependencies = [
        swapper.dependency(*swapper.split(settings.AUTH_USER_MODEL),
                           version='0004_default_groups'),
        swapper.dependency('config', 'Device'),
        ('device_monitoring', '0003_update_template'),
    ]

    operations = [
        migrations.CreateModel(
            name='WifiClient',
            fields=[
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                (
                    'mac_address',
                    models.CharField(
                        db_index=True,
                        help_text='MAC address',
                        max_length=17,
                        primary_key=True,
                        serialize=False,
                        validators=[
                            django.core.validators.RegexValidator(
                                re.compile(
                                    '^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$'
                                ),
                                code='invalid',
                                message='Must be a valid mac address.',
                            )
                        ],
                    ),
                ),
                ('vendor',
                 models.CharField(blank=True, max_length=200, null=True)),
                ('ht', models.BooleanField(default=False, verbose_name='HT')),
                ('vht', models.BooleanField(default=False,
                                            verbose_name='VHT')),
                ('wmm', models.BooleanField(default=False,
                                            verbose_name='WMM')),
                ('wds', models.BooleanField(default=False,
                                            verbose_name='WDS')),
                ('wps', models.BooleanField(default=False,
                                            verbose_name='WPS')),
            ],
            options={
                'verbose_name': 'WiFi Client',
                'abstract': False,
                'swappable': 'DEVICE_MONITORING_WIFICLIENT_MODEL',
            },
        ),
        migrations.CreateModel(
            name='WifiSession',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                (
                    'ssid',
                    models.CharField(blank=True,
                                     max_length=32,
                                     null=True,
                                     verbose_name='SSID'),
                ),
                ('interface_name', models.CharField(max_length=15)),
                (
                    'start_time',
                    models.DateTimeField(auto_now=True,
                                         db_index=True,
                                         verbose_name='start time'),
                ),
                (
                    'stop_time',
                    models.DateTimeField(blank=True,
                                         db_index=True,
                                         null=True,
                                         verbose_name='stop time'),
                ),
                (
                    'device',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=swapper.get_model_name('config', 'Device'),
                    ),
                ),
                (
                    'wifi_client',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=swapper.get_model_name('device_monitoring',
                                                  'WifiClient'),
                    ),
                ),
            ],
            options={
                'verbose_name': 'WiFi Session',
                'ordering': ('-start_time', ),
                'abstract': False,
                'swappable': 'DEVICE_MONITORING_WIFISESSION_MODEL',
            },
        ),
    ]
コード例 #22
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('sample_config', '0001_initial'),
        swapper.dependency('openwisp_users', 'Organization'),
        swapper.dependency('config', 'Device'),
    ]

    operations = [
        migrations.CreateModel(
            name='Credentials',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                ('name',
                 models.CharField(db_index=True, max_length=64, unique=True)),
                (
                    'connector',
                    models.CharField(
                        choices=connection_settings.CONNECTORS,
                        db_index=True,
                        max_length=128,
                        verbose_name='connection type',
                    ),
                ),
                (
                    'params',
                    jsonfield.fields.JSONField(
                        default=dict,
                        dump_kwargs={'indent': 4},
                        help_text='global connection parameters',
                        load_kwargs={
                            'object_pairs_hook': collections.OrderedDict
                        },
                        verbose_name='parameters',
                    ),
                ),
                (
                    'auto_add',
                    models.BooleanField(
                        default=False,
                        help_text=
                        ('automatically add these credentials to the '
                         'devices of this organization; if no organization is '
                         'specified will be added to all the new devices'),
                        verbose_name='auto add',
                    ),
                ),
                ('details',
                 models.CharField(blank=True, max_length=64, null=True)),
                (
                    'organization',
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to=swapper.get_model_name('openwisp_users',
                                                  'Organization'),
                        verbose_name='organization',
                    ),
                ),
            ],
            options={
                'verbose_name': 'Access credentials',
                'verbose_name_plural': 'Access credentials',
                'abstract': False,
            },
            bases=(
                openwisp_controller.connection.base.models.ConnectorMixin,
                openwisp_users.mixins.ValidateOrgMixin,
                models.Model,
            ),
        ),
        migrations.CreateModel(
            name='DeviceConnection',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                (
                    'update_strategy',
                    models.CharField(
                        blank=True,
                        choices=connection_settings.UPDATE_STRATEGIES,
                        db_index=True,
                        help_text='leave blank to determine automatically',
                        max_length=128,
                        verbose_name='update strategy',
                    ),
                ),
                ('enabled', models.BooleanField(db_index=True, default=True)),
                (
                    'params',
                    jsonfield.fields.JSONField(
                        blank=True,
                        default=dict,
                        dump_kwargs={'indent': 4},
                        help_text=(
                            'local connection parameters (will override the '
                            'global parameters if specified)'),
                        load_kwargs={
                            'object_pairs_hook': collections.OrderedDict
                        },
                        verbose_name='parameters',
                    ),
                ),
                (
                    'is_working',
                    models.BooleanField(blank=True, default=None, null=True),
                ),
                (
                    'failure_reason',
                    models.TextField(blank=True,
                                     verbose_name='reason of failure'),
                ),
                ('last_attempt', models.DateTimeField(blank=True, null=True)),
                ('details',
                 models.CharField(blank=True, max_length=64, null=True)),
                (
                    'credentials',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to='sample_connection.Credentials',
                    ),
                ),
                (
                    'device',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to='sample_config.Device',
                    ),
                ),
            ],
            options={
                'verbose_name': 'Device connection',
                'verbose_name_plural': 'Device connections',
                'abstract': False,
            },
            bases=(
                openwisp_controller.connection.base.models.ConnectorMixin,
                models.Model,
            ),
        ),
        migrations.CreateModel(
            name='Command',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                (
                    'status',
                    models.CharField(
                        choices=[
                            ('in-progress', 'in progress'),
                            ('success', 'success'),
                            ('failed', 'failed'),
                        ],
                        default='in-progress',
                        max_length=12,
                    ),
                ),
                (
                    'type',
                    models.CharField(
                        choices=COMMAND_CHOICES,
                        max_length=16,
                    ),
                ),
                (
                    'input',
                    jsonfield.fields.JSONField(
                        blank=True,
                        dump_kwargs={'indent': 4},
                        load_kwargs={
                            'object_pairs_hook': collections.OrderedDict
                        },
                        null=True,
                    ),
                ),
                ('output', models.TextField(blank=True)),
                (
                    'connection',
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to=swapper.get_model_name('connection',
                                                  'DeviceConnection'),
                    ),
                ),
                (
                    'device',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=swapper.get_model_name('config', 'Device'),
                    ),
                ),
            ],
            options={
                'verbose_name': 'Command',
                'verbose_name_plural': 'Commands',
                'ordering': ('created', ),
                'abstract': False,
                'swappable': swapper.swappable_setting('connection',
                                                       'Command'),
            },
        ),
    ]
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        swapper.dependency(
            *split(settings.AUTH_USER_MODEL), version='0004_default_groups'
        ),
        ('contenttypes', '0002_remove_content_type_name'),
        swapper.dependency('openwisp_notifications', 'Notifications'),
    ]

    operations = [
        migrations.CreateModel(
            name='Metric',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                ('name', models.CharField(max_length=64)),
                (
                    'configuration',
                    models.CharField(
                        choices=METRIC_CONFIGURATION_CHOICES, max_length=16, null=True
                    ),
                ),
                (
                    'key',
                    models.SlugField(
                        blank=True,
                        help_text='leave blank to determine automatically',
                        max_length=64,
                    ),
                ),
                ('field_name', models.CharField(default='value', max_length=16)),
                (
                    'object_id',
                    models.CharField(blank=True, db_index=True, max_length=36),
                ),
                (
                    'content_type',
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to='contenttypes.contenttype',
                    ),
                ),
                (
                    'is_healthy',
                    models.BooleanField(
                        blank=True, db_index=True, default=None, null=True
                    ),
                ),
            ],
            options={
                'abstract': False,
                'swappable': swapper.swappable_setting('monitoring', 'Metric'),
                'unique_together': {('key', 'field_name', 'content_type', 'object_id')},
            },
        ),
        migrations.CreateModel(
            name='Chart',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                (
                    'configuration',
                    models.CharField(
                        choices=CHART_CONFIGURATION_CHOICES, max_length=16, null=True
                    ),
                ),
                (
                    'metric',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=swapper.get_model_name('monitoring', 'Metric'),
                    ),
                ),
            ],
            options={
                'abstract': False,
                'swappable': swapper.swappable_setting('monitoring', 'Chart'),
            },
        ),
        migrations.CreateModel(
            name='AlertSettings',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                (
                    'custom_operator',
                    models.CharField(
                        blank=True,
                        choices=[('<', 'less than'), ('>', 'greater than')],
                        max_length=1,
                        null=True,
                        verbose_name='operator',
                    ),
                ),
                (
                    'custom_threshold',
                    models.FloatField(
                        blank=True,
                        help_text='threshold value',
                        null=True,
                        verbose_name='threshold value',
                    ),
                ),
                (
                    'custom_tolerance',
                    models.PositiveIntegerField(
                        blank=True,
                        help_text='for how many minutes should the threshold value be crossed before'
                        ' an alert is sent? A value of zero means the alert is sent immediately',
                        null=True,
                        validators=[django.core.validators.MaxValueValidator(10080)],
                        verbose_name='threshold tolerance',
                    ),
                ),
                (
                    'metric',
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=swapper.get_model_name('monitoring', 'Metric'),
                    ),
                ),
                (
                    'is_active',
                    models.BooleanField(
                        default=True,
                        help_text='whether alerts are enabled for this metric, uncheck to disable'
                        ' this alert for this object and all users',
                        verbose_name='Alerts enabled',
                    ),
                ),
            ],
            options={
                'verbose_name': 'Alert settings',
                'verbose_name_plural': 'Alert settings',
                'abstract': False,
                'swappable': swapper.swappable_setting('monitoring', 'AlertSettings'),
            },
        ),
    ]
コード例 #24
0
class Migration(migrations.Migration):
    initial = True

    dependencies = [
        ('pki', '0001_initial'),
        dependency(*split(settings.AUTH_USER_MODEL),
                   version='0004_default_groups'),
    ]

    operations = [
        migrations.CreateModel(
            name='Config',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                ('name', models.CharField(max_length=64, unique=True)),
                (
                    'backend',
                    models.CharField(
                        choices=[
                            ('netjsonconfig.OpenWrt', 'OpenWRT'),
                            ('netjsonconfig.OpenWisp',
                             'OpenWISP Firmware 1.x'),
                        ],
                        help_text=(
                            'Select <a href="http://netjsonconfig.openwisp.org'
                            '/en/stable/" target="_blank">netjsonconfig</a> '
                            'backend'),
                        max_length=128,
                        verbose_name='backend',
                    ),
                ),
                (
                    'config',
                    jsonfield.fields.JSONField(
                        blank=True,
                        default=dict,
                        dump_kwargs={
                            'ensure_ascii': False,
                            'indent': 4
                        },
                        help_text=
                        'configuration in NetJSON DeviceConfiguration format',
                        load_kwargs={
                            'object_pairs_hook': collections.OrderedDict
                        },
                        verbose_name='configuration',
                    ),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                (
                    'status',
                    model_utils.fields.StatusField(
                        choices=[
                            ('modified', 'modified'),
                            ('running', 'running'),
                            ('error', 'error'),
                        ],
                        default='modified',
                        help_text=
                        ('modified means the configuration is not applied '
                         'yet; running means applied and running; error means the '
                         'configuration caused issues and it was rolledback'),
                        max_length=100,
                        no_check_for_status=True,
                    ),
                ),
                (
                    'key',
                    models.CharField(
                        db_index=True,
                        default=openwisp_utils.utils.get_random_key,
                        help_text=
                        ('unique key that can be used to download the configuration'
                         ),
                        max_length=64,
                        unique=True,
                        validators=[
                            django.core.validators.RegexValidator(
                                re.compile('^[^\\s/\\.]+$', 32),
                                code='invalid',
                                message=
                                'Key must not contain spaces, dots or slashes.',
                            )
                        ],
                    ),
                ),
                (
                    'mac_address',
                    models.CharField(
                        help_text='primary mac address',
                        max_length=17,
                        unique=True,
                        validators=[
                            django.core.validators.RegexValidator(
                                re.compile(
                                    '^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})',
                                    32),
                                code='invalid',
                                message='Must be a valid mac address.',
                            )
                        ],
                    ),
                ),
                (
                    'last_ip',
                    models.GenericIPAddressField(
                        blank=True,
                        help_text=('indicates the last ip from which the '
                                   'configuration was downloaded from (except '
                                   'downloads from this page)'),
                        null=True,
                    ),
                ),
                (
                    'organization',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=get_model_name('openwisp_users', 'Organization'),
                        verbose_name='organization',
                    ),
                ),
            ],
            options={
                'verbose_name': 'configuration',
                'verbose_name_plural': 'configurations',
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='OrganizationConfigSettings',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'registration_enabled',
                    models.BooleanField(
                        default=True,
                        help_text=(
                            'Whether automatic registration of devices is '
                            'enabled or not'),
                        verbose_name='auto-registration enabled',
                    ),
                ),
                (
                    'shared_secret',
                    openwisp_utils.base.KeyField(
                        db_index=True,
                        default=openwisp_utils.utils.get_random_key,
                        help_text='used for automatic registration of devices',
                        max_length=32,
                        unique=True,
                        validators=[
                            django.core.validators.RegexValidator(
                                re.compile('^[^\\s/\\.]+$'),
                                code='invalid',
                                message=(
                                    'This value must not contain spaces, dots '
                                    'or slashes.'),
                            )
                        ],
                        verbose_name='shared secret',
                    ),
                ),
                (
                    'organization',
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name='config_settings',
                        to=get_model_name('openwisp_users', 'Organization'),
                        verbose_name='organization',
                    ),
                ),
            ],
            options={
                'verbose_name': 'Configuration management settings',
                'verbose_name_plural': 'Configuration management settings',
            },
        ),
        migrations.CreateModel(
            name='Template',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                ('name', models.CharField(max_length=64, unique=True)),
                (
                    'backend',
                    models.CharField(
                        choices=[
                            ('netjsonconfig.OpenWrt', 'OpenWRT'),
                            ('netjsonconfig.OpenWisp',
                             'OpenWISP Firmware 1.x'),
                        ],
                        help_text=
                        ('Select <a href="http://netjsonconfig.openwisp.org'
                         '/en/stable/" target="_blank">netjsonconfig</a> backend'
                         ),
                        max_length=128,
                        verbose_name='backend',
                    ),
                ),
                (
                    'config',
                    jsonfield.fields.JSONField(
                        blank=True,
                        default=dict,
                        dump_kwargs={
                            'ensure_ascii': False,
                            'indent': 4
                        },
                        help_text=
                        'configuration in NetJSON DeviceConfiguration format',
                        load_kwargs={
                            'object_pairs_hook': collections.OrderedDict
                        },
                        verbose_name='configuration',
                    ),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                (
                    'type',
                    models.CharField(
                        choices=[('generic', 'Generic'),
                                 ('vpn', 'VPN-client')],
                        db_index=True,
                        default='generic',
                        help_text=
                        ('template type, determines which features are available'
                         ),
                        max_length=16,
                        verbose_name='type',
                    ),
                ),
                (
                    'default',
                    models.BooleanField(
                        db_index=True,
                        default=False,
                        help_text=('whether new configurations will have this '
                                   'template enabled by default'),
                        verbose_name='enabled by default',
                    ),
                ),
                (
                    'auto_cert',
                    models.BooleanField(
                        db_index=True,
                        default=(openwisp_controller.config.base.template.
                                 default_auto_cert),
                        help_text=
                        ('whether x509 client certificates should be automatically '
                         'managed behind the scenes for each configuration '
                         'using this template, valid only for the VPN type'),
                        verbose_name='auto certificate',
                    ),
                ),
                (
                    'organization',
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to=get_model_name('openwisp_users', 'Organization'),
                        verbose_name='organization',
                    ),
                ),
            ],
            options={
                'verbose_name': 'template',
                'verbose_name_plural': 'templates',
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Vpn',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                ('name', models.CharField(max_length=64, unique=True)),
                (
                    'config',
                    jsonfield.fields.JSONField(
                        default=dict,
                        dump_kwargs={
                            'ensure_ascii': False,
                            'indent': 4
                        },
                        help_text=
                        'configuration in NetJSON DeviceConfiguration format',
                        load_kwargs={
                            'object_pairs_hook': collections.OrderedDict
                        },
                        verbose_name='configuration',
                    ),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                (
                    'host',
                    models.CharField(
                        help_text='VPN server hostname or ip address',
                        max_length=64),
                ),
                (
                    'backend',
                    models.CharField(
                        choices=app_settings.VPN_BACKENDS,
                        help_text='Select VPN configuration backend',
                        max_length=128,
                        verbose_name='VPN backend',
                    ),
                ),
                ('notes', models.TextField(blank=True)),
                ('dh', models.TextField(blank=True)),
                (
                    'ca',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to='pki.Ca',
                        verbose_name='Certification Authority',
                    ),
                ),
                (
                    'cert',
                    models.ForeignKey(
                        blank=True,
                        help_text='leave blank to create automatically',
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to='pki.Cert',
                        verbose_name='x509 Certificate',
                    ),
                ),
                (
                    'organization',
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to=get_model_name('openwisp_users', 'Organization'),
                        verbose_name='organization',
                    ),
                ),
            ],
            options={
                'verbose_name': 'VPN server',
                'verbose_name_plural': 'VPN servers',
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='VpnClient',
            fields=[
                (
                    'id',
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name='ID',
                    ),
                ),
                ('auto_cert', models.BooleanField(default=False)),
                (
                    'cert',
                    models.OneToOneField(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to='pki.Cert',
                    ),
                ),
                (
                    'config',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to='config.Config'),
                ),
                (
                    'vpn',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to='config.Vpn'),
                ),
            ],
            options={
                'verbose_name': 'VPN client',
                'verbose_name_plural': 'VPN clients',
                'abstract': False,
            },
        ),
        migrations.AddField(
            model_name='template',
            name='vpn',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to='config.Vpn',
                verbose_name='VPN',
            ),
        ),
        migrations.AddField(
            model_name='config',
            name='templates',
            field=SortedManyToManyField(
                blank=True,
                help_text='configuration templates, applied from first to last',
                related_name='config_relations',
                to='config.Template',
                verbose_name='templates',
            ),
        ),
        migrations.AddField(
            model_name='config',
            name='vpn',
            field=models.ManyToManyField(
                blank=True,
                related_name='vpn_relations',
                through='config.VpnClient',
                to='config.Vpn',
            ),
        ),
        migrations.AlterUniqueTogether(name='vpnclient',
                                       unique_together=set([('config', 'vpn')
                                                            ])),
    ]
コード例 #25
0
class Migration(migrations.Migration):

    dependencies = [
        ('cities', '0002_continent_models_and_foreign_keys'),
        swapper.dependency('cities', 'Continent'),
        swapper.dependency('cities', 'Country'),
        swapper.dependency('cities', 'City'),
    ]

    operations = [
        migrations.AlterField(
            model_name='city',
            name='country',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name='cities',
                to=swapper.get_model_name('cities', 'Country')),
        ),
        migrations.AlterField(
            model_name='city',
            name='region',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name='cities',
                to='cities.Region'),
        ),
        migrations.AlterField(
            model_name='city',
            name='subregion',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name='cities',
                to='cities.Subregion'),
        ),
        migrations.AlterField(
            model_name='continent',
            name='alt_names',
            field=models.ManyToManyField(to='cities.AlternativeName'),
        ),
        migrations.AlterField(
            model_name='continent',
            name='slug',
            field=models.CharField(max_length=200),
        ),
        migrations.AlterField(
            model_name='country',
            name='tld',
            field=models.CharField(max_length=5, verbose_name='TLD'),
        ),
        migrations.AlterField(
            model_name='district',
            name='city',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name='districts',
                to=swapper.get_model_name('cities', 'City')),
        ),
        migrations.AlterField(
            model_name='region',
            name='country',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name='regions',
                to=swapper.get_model_name('cities', 'Country')),
        ),
        migrations.AlterField(
            model_name='subregion',
            name='region',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name='subregions',
                to='cities.Region'),
        ),
    ]
コード例 #26
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        swapper.dependency('django_freeradius', 'RadiusReply'),
        swapper.dependency('django_freeradius', 'RadiusCheck'),
    ]

    operations = [
        migrations.CreateModel(
            name='Nas',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('name', models.CharField(db_column='nasname', db_index=True, help_text='NAS Name (or IP address)', max_length=128, unique=True, verbose_name='name')),
                ('short_name', models.CharField(db_column='shortname', max_length=32, verbose_name='short name')),
                ('type', models.CharField(max_length=30, verbose_name='type')),
                ('secret', models.CharField(help_text='Shared Secret', max_length=60, verbose_name='secret')),
                ('ports', models.IntegerField(blank=True, null=True, verbose_name='ports')),
                ('community', models.CharField(blank=True, max_length=50, null=True, verbose_name='community')),
                ('description', models.CharField(max_length=200, null=True, verbose_name='description')),
                ('server', models.CharField(max_length=64, null=True, verbose_name='server')),
            ],
            options={
                'swappable': swapper.swappable_setting('django_freeradius', 'Nas'),
                'db_table': 'nas',
                'verbose_name_plural': 'NAS',
                'abstract': False,
                'verbose_name': 'NAS',
            },
        ),
        migrations.CreateModel(
            name='RadiusAccounting',
            fields=[
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('rad_acct_id', models.BigIntegerField(db_column='radacctid', primary_key=True, serialize=False, verbose_name='RADIUS accounting ID')),
                ('acct_session_id', models.CharField(db_column='acctsessionid', db_index=True, max_length=64, verbose_name='accounting session ID')),
                ('acct_unique_id', models.CharField(db_column='acctuniqueid', max_length=32, unique=True, verbose_name='accounting unique ID')),
                ('username', models.CharField(db_index=True, max_length=64, verbose_name='username')),
                ('groupname', models.CharField(max_length=64, verbose_name='group name')),
                ('realm', models.CharField(max_length=64, null=True, verbose_name='realm')),
                ('nas_ip_address', models.CharField(db_column='nasipaddress', db_index=True, max_length=15, verbose_name='NAS IP address')),
                ('nas_port_id', models.CharField(db_column='nasportid', max_length=15, null=True, verbose_name='NAS port ID')),
                ('nas_port_type', models.CharField(db_column='nasporttype', max_length=32, verbose_name='NAS port type')),
                ('acct_start_time', models.DateTimeField(db_column='acctstarttime', db_index=True, verbose_name='Accounting start time')),
                ('acct_stop_time', models.DateTimeField(db_column='acctstoptime', db_index=True, null=True, verbose_name='Accounting stop time')),
                ('acct_session_time', models.IntegerField(db_column='acctsessiontime', db_index=True, null=True, verbose_name='Accounting session time')),
                ('acct_authentic', models.CharField(db_column='acctauthentic', max_length=32, null=True, verbose_name='Accounting authentication')),
                ('connection_info_start', models.CharField(db_column='connectinfo_start', max_length=50, null=True, verbose_name='connection info start')),
                ('connection_info_stop', models.CharField(db_column='connectinfo_stop', max_length=50, null=True, verbose_name='connection info stop')),
                ('acct_input_octets', models.BigIntegerField(db_column='acctinputoctets', null=True, verbose_name='accounting input octets')),
                ('acct_output_octets', models.BigIntegerField(db_column='acctoutputoctets', null=True, verbose_name='accounting output octets')),
                ('calling_station_id', models.CharField(db_column='calledstationid', max_length=50, verbose_name='calling station ID')),
                ('called_station_id', models.CharField(db_column='callingstationid', max_length=50, verbose_name='called station ID')),
                ('acct_terminate_cause', models.CharField(db_column='acctterminatecause', max_length=32, verbose_name='accounting termination cause')),
                ('service_type', models.CharField(db_column='servicetype', max_length=32, null=True, verbose_name='service type')),
                ('framed_protocol', models.CharField(db_column='framedprotocol', max_length=32, null=True, verbose_name='framed protocol')),
                ('framed_ip_address', models.CharField(db_column='framedipaddress', db_index=True, max_length=15, verbose_name='framed IP address')),
                ('acct_start_delay', models.IntegerField(db_column='acctstartdelay', null=True, verbose_name='accounting start delay')),
                ('acct_stop_delay', models.IntegerField(db_column='acctstopdelay', null=True, verbose_name='accounting stop delay')),
                ('xascend_session_svrkey', models.CharField(db_column='xascendsessionsvrkey', max_length=10, null=True, verbose_name='xascend session svrkey')),
            ],
            options={
                'swappable': swapper.swappable_setting('django_freeradius', 'RadiusAccounting'),
                'db_table': 'radacct',
                'verbose_name_plural': 'accountings',
                'abstract': False,
                'verbose_name': 'accounting',
            },
        ),
        migrations.CreateModel(
            name='RadiusCheck',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('username', models.CharField(db_index=True, max_length=64, verbose_name='username')),
                ('value', models.CharField(max_length=253, verbose_name='value')),
                ('op', models.CharField(choices=[('=', '='), (':=', ':='), ('==', '=='), ('+=', '+='), ('!=', '!='), ('>', '>'), ('>=', '>='), ('<', '<'), ('<=', '<='), ('=~', '=~'), ('!~', '!~'), ('=*', '=*'), ('!*', '!*')], default=':=', max_length=2, verbose_name='operator')),
                ('attribute', models.CharField(max_length=64, verbose_name='attribute')),
            ],
            options={
                'swappable': swapper.swappable_setting('django_freeradius', 'RadiusCheck'),
                'db_table': 'radcheck',
                'verbose_name_plural': 'radius checks',
                'abstract': False,
                'verbose_name': 'radius check',
            },
        ),
        migrations.CreateModel(
            name='RadiusGroup',
            fields=[
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('id', models.UUIDField(db_column='id', primary_key=True, serialize=False)),
                ('groupname', models.CharField(db_index=True, max_length=255, unique=True, verbose_name='group name')),
                ('priority', models.IntegerField(default=1, verbose_name='priority')),
                ('notes', models.CharField(blank=True, max_length=64, null=True, verbose_name='notes')),
            ],
            options={
                'swappable': swapper.swappable_setting('django_freeradius', 'RadiusGroup'),
                'db_table': 'radiusgroup',
                'verbose_name_plural': 'radius groups',
                'abstract': False,
                'verbose_name': 'radius group',
            },
        ),
        migrations.CreateModel(
            name='RadiusGroupCheck',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('groupname', models.CharField(db_index=True, max_length=64, verbose_name='group name')),
                ('attribute', models.CharField(max_length=64, verbose_name='attribute')),
                ('op', models.CharField(choices=[('=', '='), (':=', ':='), ('==', '=='), ('+=', '+='), ('!=', '!='), ('>', '>'), ('>=', '>='), ('<', '<'), ('<=', '<='), ('=~', '=~'), ('!~', '!~'), ('=*', '=*'), ('!*', '!*')], default=':=', max_length=2, verbose_name='operator')),
                ('value', models.CharField(max_length=253, verbose_name='value')),
            ],
            options={
                'swappable': swapper.swappable_setting('django_freeradius', 'RadiusGroupCheck'),
                'db_table': 'radgroupcheck',
                'verbose_name_plural': 'radius group checks',
                'abstract': False,
                'verbose_name': 'radius group check',
            },
        ),
        migrations.CreateModel(
            name='RadiusGroupReply',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('groupname', models.CharField(db_index=True, max_length=64, verbose_name='group name')),
                ('attribute', models.CharField(max_length=64, verbose_name='attribute')),
                ('op', models.CharField(choices=[('=', '='), (':=', ':='), ('+=', '+=')], default='=', max_length=2, verbose_name='operator')),
                ('value', models.CharField(max_length=253, verbose_name='value')),
            ],
            options={
                'swappable': swapper.swappable_setting('django_freeradius', 'RadiusGroupReply'),
                'db_table': 'radgroupreply',
                'verbose_name_plural': 'radius group replies',
                'abstract': False,
                'verbose_name': 'radius group reply',
            },
        ),
        migrations.CreateModel(
            name='RadiusGroupUsers',
            fields=[
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('id', models.UUIDField(db_column='id', primary_key=True, serialize=False)),
                ('username', models.CharField(max_length=64, unique=True, verbose_name='username')),
                ('groupname', models.CharField(max_length=255, unique=True, verbose_name='group name')),
                ('radius_check', models.ManyToManyField(blank=True, db_column='radiuscheck', to=settings.DJANGO_FREERADIUS_RADIUSCHECK_MODEL, verbose_name='radius check')),
            ],
            options={
                'swappable': swapper.swappable_setting('django_freeradius', 'RadiusGroupUsers'),
                'db_table': 'radiusgroupusers',
                'verbose_name_plural': 'radius group users',
                'abstract': False,
                'verbose_name': 'radius group users',
            },
        ),
        migrations.CreateModel(
            name='RadiusPostAuth',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('username', models.CharField(max_length=64, verbose_name='username')),
                ('password', models.CharField(db_column='pass', max_length=64, verbose_name='password')),
                ('reply', models.CharField(max_length=32, verbose_name='reply')),
                ('date', models.DateTimeField(auto_now_add=True, db_column='authdate', verbose_name='date')),
            ],
            options={
                'swappable': swapper.swappable_setting('django_freeradius', 'RadiusPostAuth'),
                'db_table': 'radpostauth',
                'verbose_name_plural': 'radius post authentication logs',
                'abstract': False,
                'verbose_name': 'radius post authentication log',
            },
        ),
        migrations.CreateModel(
            name='RadiusReply',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('username', models.CharField(db_index=True, max_length=64, verbose_name='username')),
                ('value', models.CharField(max_length=253, verbose_name='value')),
                ('op', models.CharField(choices=[('=', '='), (':=', ':='), ('+=', '+=')], default='=', max_length=2, verbose_name='operator')),
                ('attribute', models.CharField(max_length=64, verbose_name='attribute')),
            ],
            options={
                'swappable': swapper.swappable_setting('django_freeradius', 'RadiusReply'),
                'db_table': 'radreply',
                'verbose_name_plural': 'radius replies',
                'abstract': False,
                'verbose_name': 'radius reply',
            },
        ),
        migrations.CreateModel(
            name='RadiusUserGroup',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')),
                ('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')),
                ('username', models.CharField(db_index=True, max_length=64, verbose_name='username')),
                ('groupname', models.CharField(max_length=64, verbose_name='group name')),
                ('priority', models.IntegerField(default=1, verbose_name='priority')),
            ],
            options={
                'swappable': swapper.swappable_setting('django_freeradius', 'RadiusUserGroup'),
                'db_table': 'radusergroup',
                'verbose_name_plural': 'radius user group associations',
                'abstract': False,
                'verbose_name': 'radius user group association',
            },
        ),
        migrations.AddField(
            model_name='radiusgroupusers',
            name='radius_reply',
            field=models.ManyToManyField(blank=True, db_column='radiusreply', to=settings.DJANGO_FREERADIUS_RADIUSREPLY_MODEL, verbose_name='radius reply'),
        ),
    ]
コード例 #27
0
 def test_swap_dependency(self):
     self.assertEqual(
         swapper.dependency("default_app", "Type"),
         ("alt_app", "__first__")
     )
コード例 #28
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        swapper.dependency(*swapper.split(settings.AUTH_USER_MODEL),
                           version='0004_default_groups'),
        swapper.dependency('config', 'Device'),
    ]

    operations = [
        migrations.CreateModel(
            name='DeviceLocation',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                (
                    'indoor',
                    models.CharField(
                        blank=True,
                        max_length=64,
                        null=True,
                        verbose_name='indoor position',
                    ),
                ),
                (
                    'content_object',
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=swapper.get_model_name('config', 'Device'),
                    ),
                ),
            ],
            options={'abstract': False},
            bases=(openwisp_users.mixins.ValidateOrgMixin, models.Model),
        ),
        migrations.CreateModel(
            name='FloorPlan',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                ('floor', models.SmallIntegerField(verbose_name='floor')),
                (
                    'image',
                    models.ImageField(
                        help_text='floor plan image',
                        storage=django_loci.storage.OverwriteStorage(),
                        upload_to=django_loci.storage.OverwriteStorage.
                        upload_to,
                        verbose_name='image',
                    ),
                ),
            ],
            options={'abstract': False},
            bases=(openwisp_users.mixins.ValidateOrgMixin, models.Model),
        ),
        migrations.CreateModel(
            name='Location',
            fields=[
                (
                    'id',
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                (
                    'name',
                    models.CharField(
                        help_text=('A descriptive name of the location '
                                   '(building name, company name, etc.)'),
                        max_length=75,
                        verbose_name='name',
                    ),
                ),
                (
                    'type',
                    models.CharField(
                        choices=[
                            (
                                'outdoor',
                                ('Outdoor environment (eg: street, square, garden, '
                                 'land)'),
                            ),
                            (
                                'indoor',
                                ('Indoor environment (eg: building, roofs, subway, '
                                 'large vehicles)'),
                            ),
                        ],
                        db_index=True,
                        help_text=
                        ('indoor locations can have floorplans associated to them'
                         ),
                        max_length=8,
                    ),
                ),
                (
                    'is_mobile',
                    models.BooleanField(
                        db_index=True,
                        default=False,
                        help_text='is this location a moving object?',
                        verbose_name='is mobile?',
                    ),
                ),
                (
                    'address',
                    models.CharField(
                        blank=True,
                        db_index=True,
                        max_length=256,
                        verbose_name='address',
                    ),
                ),
                (
                    'geometry',
                    django.contrib.gis.db.models.fields.GeometryField(
                        blank=True,
                        null=True,
                        srid=4326,
                        verbose_name='geometry'),
                ),
                (
                    'organization',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=swapper.get_model_name('openwisp_users',
                                                  'Organization'),
                        verbose_name='organization',
                    ),
                ),
            ],
            options={'abstract': False},
            bases=(openwisp_users.mixins.ValidateOrgMixin, models.Model),
        ),
        migrations.AddField(
            model_name='floorplan',
            name='location',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to='geo.Location'),
        ),
        migrations.AddField(
            model_name='floorplan',
            name='organization',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to=swapper.get_model_name('openwisp_users', 'Organization'),
                verbose_name='organization',
            ),
        ),
        migrations.AddField(
            model_name='devicelocation',
            name='floorplan',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.PROTECT,
                to='geo.FloorPlan',
            ),
        ),
        migrations.AddField(
            model_name='devicelocation',
            name='location',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.PROTECT,
                to='geo.Location',
            ),
        ),
        migrations.AlterUniqueTogether(name='floorplan',
                                       unique_together=set([('location',
                                                             'floor')])),
    ]
コード例 #29
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [swapper.dependency('django_orghierarchy', 'DataSource')]

    operations = [
        migrations.CreateModel(
            name='DataSource',
            fields=[
                ('id',
                 models.CharField(max_length=100,
                                  primary_key=True,
                                  serialize=False)),
                ('name', models.CharField(max_length=255)),
            ],
            options={
                'swappable':
                swapper.swappable_setting('django_orghierarchy', 'DataSource'),
            },
        ),
        migrations.CreateModel(
            name='Organization',
            fields=[
                ('id',
                 models.CharField(editable=False,
                                  max_length=255,
                                  primary_key=True,
                                  serialize=False)),
                ('origin_id', models.CharField(max_length=255, unique=True)),
                ('name',
                 models.CharField(
                     help_text='A primary name, e.g. a legally recognized name',
                     max_length=255)),
                ('founding_date',
                 models.DateField(blank=True,
                                  help_text='A date of founding',
                                  null=True)),
                ('dissolution_date',
                 models.DateField(blank=True,
                                  help_text='A date of dissolution',
                                  null=True)),
                ('created_time',
                 models.DateTimeField(
                     auto_now_add=True,
                     help_text='The time at which the resource was created')),
                ('last_modified_time',
                 models.DateTimeField(
                     auto_now=True,
                     help_text='The time at which the resource was updated')),
                ('lft',
                 models.PositiveIntegerField(db_index=True, editable=False)),
                ('rght',
                 models.PositiveIntegerField(db_index=True, editable=False)),
                ('tree_id',
                 models.PositiveIntegerField(db_index=True, editable=False)),
                ('level',
                 models.PositiveIntegerField(db_index=True, editable=False)),
            ],
        ),
        migrations.CreateModel(
            name='OrganizationClass',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=255, unique=True)),
            ],
            options={
                'verbose_name_plural': 'Organization classes',
                'verbose_name': 'Organization class',
            },
        ),
        migrations.AddField(
            model_name='organization',
            name='classification',
            field=models.ForeignKey(
                blank=True,
                help_text='An organization category, e.g. committee',
                null=True,
                on_delete=django.db.models.deletion.PROTECT,
                to='django_orghierarchy.OrganizationClass'),
        ),
        migrations.AddField(
            model_name='organization',
            name='created_by',
            field=models.ForeignKey(
                blank=True,
                editable=False,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name='created_organizations',
                to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='organization',
            name='data_source',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to=swapper.get_model_name('django_orghierarchy',
                                          'DataSource')),
        ),
        migrations.AddField(
            model_name='organization',
            name='last_modified_by',
            field=models.ForeignKey(
                blank=True,
                editable=False,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name='modified_organizations',
                to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='organization',
            name='parent',
            field=mptt.fields.TreeForeignKey(
                blank=True,
                help_text='The organizations that contain this organization',
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name='children',
                to='django_orghierarchy.Organization'),
        ),
        migrations.AddField(
            model_name='organization',
            name='responsible_organization',
            field=models.ForeignKey(
                blank=True,
                help_text='Responsible organization',
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name='affiliated_organization',
                to='django_orghierarchy.Organization'),
        ),
        migrations.AlterUniqueTogether(
            name='organization',
            unique_together=set([('data_source', 'origin_id')]),
        ),
        migrations.AddField(
            model_name='organization',
            name='admin_users',
            field=models.ManyToManyField(blank=True,
                                         related_name='admin_organizations',
                                         to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='organization',
            name='regular_users',
            field=models.ManyToManyField(
                blank=True,
                related_name='organization_memberships',
                to=settings.AUTH_USER_MODEL),
        ),
    ]
コード例 #30
0
 def test_swap_dependency(self):
     self.assertEqual(
         swapper.dependency("default_app", "Type"),
         ("alt_app", "__first__")
     )
コード例 #31
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        swapper.dependency(*swapper.split(settings.AUTH_USER_MODEL),
                           version='0004_default_groups'),
    ]

    operations = [
        migrations.CreateModel(
            name='Ca',
            fields=[
                (
                    'id',
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name='ID',
                    ),
                ),
                ('name', models.CharField(max_length=64)),
                ('notes', models.TextField(blank=True)),
                (
                    'key_length',
                    models.CharField(
                        blank=True,
                        choices=[
                            ('', ''),
                            ('512', '512'),
                            ('1024', '1024'),
                            ('2048', '2048'),
                            ('4096', '4096'),
                        ],
                        default=django_x509.base.models.default_key_length,
                        help_text='bits',
                        max_length=6,
                        verbose_name='key length',
                    ),
                ),
                (
                    'digest',
                    models.CharField(
                        blank=True,
                        choices=[
                            ('', ''),
                            ('sha1', 'SHA1'),
                            ('sha224', 'SHA224'),
                            ('sha256', 'SHA256'),
                            ('sha384', 'SHA384'),
                            ('sha512', 'SHA512'),
                        ],
                        default=django_x509.base.models.
                        default_digest_algorithm,
                        help_text='bits',
                        max_length=8,
                        verbose_name='digest algorithm',
                    ),
                ),
                (
                    'validity_start',
                    models.DateTimeField(
                        blank=True,
                        default=django_x509.base.models.default_validity_start,
                        null=True,
                    ),
                ),
                (
                    'validity_end',
                    models.DateTimeField(
                        blank=True,
                        default=django_x509.base.models.
                        default_ca_validity_end,
                        null=True,
                    ),
                ),
                ('country_code', models.CharField(blank=True, max_length=2)),
                (
                    'state',
                    models.CharField(blank=True,
                                     max_length=64,
                                     verbose_name='state or province'),
                ),
                (
                    'city',
                    models.CharField(blank=True,
                                     max_length=64,
                                     verbose_name='city'),
                ),
                (
                    'organization_name',
                    models.CharField(blank=True,
                                     max_length=64,
                                     verbose_name='organization'),
                ),
                (
                    'organizational_unit_name',
                    models.CharField(
                        blank=True,
                        max_length=64,
                        verbose_name='organizational unit name',
                    ),
                ),
                (
                    'email',
                    models.EmailField(blank=True,
                                      max_length=254,
                                      verbose_name='email address'),
                ),
                (
                    'common_name',
                    models.CharField(blank=True,
                                     max_length=64,
                                     verbose_name='common name'),
                ),
                (
                    'extensions',
                    jsonfield.fields.JSONField(
                        blank=True,
                        default=list,
                        dump_kwargs={'indent': 4},
                        help_text='additional x509 certificate extensions',
                        load_kwargs={
                            'object_pairs_hook': collections.OrderedDict
                        },
                        verbose_name='extensions',
                    ),
                ),
                (
                    'serial_number',
                    models.CharField(
                        blank=True,
                        help_text='leave blank to determine automatically',
                        max_length=48,
                        null=True,
                        verbose_name='serial number',
                    ),
                ),
                (
                    'certificate',
                    models.TextField(
                        blank=True,
                        help_text='certificate in X.509 PEM format'),
                ),
                (
                    'private_key',
                    models.TextField(
                        blank=True,
                        help_text='private key in X.509 PEM format'),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                (
                    'passphrase',
                    models.CharField(
                        blank=True,
                        help_text='Passphrase for the private key, if present',
                        max_length=64,
                    ),
                ),
                ('details',
                 models.CharField(blank=True, max_length=64, null=True)),
                (
                    'organization',
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to=swapper.get_model_name('openwisp_users',
                                                  'Organization'),
                        verbose_name='organization',
                    ),
                ),
            ],
            options={
                'verbose_name': 'CA',
                'verbose_name_plural': 'CAs',
                'abstract': False,
            },
            bases=(openwisp_users.mixins.ValidateOrgMixin, models.Model),
        ),
        migrations.CreateModel(
            name='Cert',
            fields=[
                (
                    'id',
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name='ID',
                    ),
                ),
                ('name', models.CharField(max_length=64)),
                ('notes', models.TextField(blank=True)),
                (
                    'key_length',
                    models.CharField(
                        blank=True,
                        choices=[
                            ('', ''),
                            ('512', '512'),
                            ('1024', '1024'),
                            ('2048', '2048'),
                            ('4096', '4096'),
                        ],
                        default=django_x509.base.models.default_key_length,
                        help_text='bits',
                        max_length=6,
                        verbose_name='key length',
                    ),
                ),
                (
                    'digest',
                    models.CharField(
                        blank=True,
                        choices=[
                            ('', ''),
                            ('sha1', 'SHA1'),
                            ('sha224', 'SHA224'),
                            ('sha256', 'SHA256'),
                            ('sha384', 'SHA384'),
                            ('sha512', 'SHA512'),
                        ],
                        default=django_x509.base.models.
                        default_digest_algorithm,
                        help_text='bits',
                        max_length=8,
                        verbose_name='digest algorithm',
                    ),
                ),
                (
                    'validity_start',
                    models.DateTimeField(
                        blank=True,
                        default=django_x509.base.models.default_validity_start,
                        null=True,
                    ),
                ),
                (
                    'validity_end',
                    models.DateTimeField(
                        blank=True,
                        default=django_x509.base.models.
                        default_cert_validity_end,
                        null=True,
                    ),
                ),
                ('country_code', models.CharField(blank=True, max_length=2)),
                (
                    'state',
                    models.CharField(blank=True,
                                     max_length=64,
                                     verbose_name='state or province'),
                ),
                (
                    'city',
                    models.CharField(blank=True,
                                     max_length=64,
                                     verbose_name='city'),
                ),
                (
                    'organization_name',
                    models.CharField(blank=True,
                                     max_length=64,
                                     verbose_name='organization'),
                ),
                (
                    'organizational_unit_name',
                    models.CharField(
                        blank=True,
                        max_length=64,
                        verbose_name='organizational unit name',
                    ),
                ),
                (
                    'email',
                    models.EmailField(blank=True,
                                      max_length=254,
                                      verbose_name='email address'),
                ),
                (
                    'common_name',
                    models.CharField(blank=True,
                                     max_length=64,
                                     verbose_name='common name'),
                ),
                (
                    'extensions',
                    jsonfield.fields.JSONField(
                        blank=True,
                        default=list,
                        dump_kwargs={'indent': 4},
                        help_text='additional x509 certificate extensions',
                        load_kwargs={
                            'object_pairs_hook': collections.OrderedDict
                        },
                        verbose_name='extensions',
                    ),
                ),
                (
                    'serial_number',
                    models.CharField(
                        blank=True,
                        help_text='leave blank to determine automatically',
                        max_length=48,
                        null=True,
                        verbose_name='serial number',
                    ),
                ),
                (
                    'certificate',
                    models.TextField(
                        blank=True,
                        help_text='certificate in X.509 PEM format'),
                ),
                (
                    'private_key',
                    models.TextField(
                        blank=True,
                        help_text='private key in X.509 PEM format'),
                ),
                (
                    'created',
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='created',
                    ),
                ),
                (
                    'modified',
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name='modified',
                    ),
                ),
                (
                    'passphrase',
                    models.CharField(
                        blank=True,
                        help_text='Passphrase for the private key, if present',
                        max_length=64,
                    ),
                ),
                ('revoked',
                 models.BooleanField(default=False, verbose_name='revoked')),
                (
                    'revoked_at',
                    models.DateTimeField(blank=True,
                                         default=None,
                                         null=True,
                                         verbose_name='revoked at'),
                ),
                ('details',
                 models.CharField(blank=True, max_length=64, null=True)),
                (
                    'ca',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to='sample_pki.Ca',
                        verbose_name='CA',
                    ),
                ),
                (
                    'organization',
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to=swapper.get_model_name('openwisp_users',
                                                  'Organization'),
                        verbose_name='organization',
                    ),
                ),
            ],
            options={
                'verbose_name': 'certificate',
                'verbose_name_plural': 'certificates',
                'abstract': False,
                'unique_together': {('ca', 'serial_number')},
            },
            bases=(openwisp_users.mixins.ValidateOrgMixin, models.Model),
        ),
        migrations.AddConstraint(
            model_name='ca',
            constraint=models.UniqueConstraint(
                fields=('common_name', 'organization'),
                name='sample_pki_ca_comman_name_and_organization_is_unique',
            ),
        ),
        migrations.AddConstraint(
            model_name='cert',
            constraint=models.UniqueConstraint(
                fields=('common_name', 'organization'),
                name='sample_pki_cert_comman_name_and_organization_is_unique',
            ),
        ),
    ]
コード例 #32
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import swapper
from django.db import models, migrations
from decimal import Decimal
import model_utils.fields
import django.utils.timezone
from django.conf import settings

dependancies = [
    migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ('contenttypes', '0001_initial'),
]

swappable_dep = swapper.dependency('star_ratings', 'Rating')
if swappable_dep == migrations.swappable_dependency('star_ratings.Rating'):
    dependancies.append(swappable_dep)


class Migration(migrations.Migration):
    dependencies = dependancies

    operations = [
        migrations.CreateModel(
            name='Rating',
            fields=[
                ('id', models.AutoField(verbose_name='ID', auto_created=True, primary_key=True, serialize=False)),
                ('count', models.PositiveIntegerField(default=0)),
                ('total', models.PositiveIntegerField(default=0)),
                ('average', models.DecimalField(decimal_places=3, max_digits=6, default=Decimal('0'))),