From 743cf6d3982009f0a83407a856597025cbec76a8 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 29 Jun 2018 09:44:32 -0400 Subject: [PATCH] Added description to ConfigContext --- netbox/extras/api/serializers.py | 4 +++- netbox/extras/forms.py | 4 +++- .../{0014_config-contexts.py => 0014_configcontexts.py} | 3 ++- netbox/extras/models.py | 4 ++++ netbox/extras/tables.py | 2 +- netbox/templates/extras/configcontext_edit.html | 6 ++++++ netbox/templates/extras/object_configcontext.html | 3 +++ 7 files changed, 22 insertions(+), 4 deletions(-) rename netbox/extras/migrations/{0014_config-contexts.py => 0014_configcontexts.py} (95%) diff --git a/netbox/extras/api/serializers.py b/netbox/extras/api/serializers.py index a64acc1a4..d6a7d5079 100644 --- a/netbox/extras/api/serializers.py +++ b/netbox/extras/api/serializers.py @@ -140,7 +140,9 @@ class ConfigContextSerializer(ValidatedModelSerializer): class Meta: model = ConfigContext - fields = ['name', 'weight', 'is_active', 'regions', 'sites', 'roles', 'platforms', 'tenants', 'data'] + fields = [ + 'name', 'weight', 'description', 'is_active', 'regions', 'sites', 'roles', 'platforms', 'tenants', 'data', + ] # diff --git a/netbox/extras/forms.py b/netbox/extras/forms.py index bd7ace840..ea373cf4f 100644 --- a/netbox/extras/forms.py +++ b/netbox/extras/forms.py @@ -197,7 +197,9 @@ class ConfigContextForm(BootstrapMixin, forms.ModelForm): class Meta: model = ConfigContext - fields = ['name', 'weight', 'is_active', 'regions', 'sites', 'roles', 'platforms', 'tenants', 'data'] + fields = [ + 'name', 'weight', 'description', 'is_active', 'regions', 'sites', 'roles', 'platforms', 'tenants', 'data', + ] # diff --git a/netbox/extras/migrations/0014_config-contexts.py b/netbox/extras/migrations/0014_configcontexts.py similarity index 95% rename from netbox/extras/migrations/0014_config-contexts.py rename to netbox/extras/migrations/0014_configcontexts.py index 5d8d46d6f..bc12e2cdf 100644 --- a/netbox/extras/migrations/0014_config-contexts.py +++ b/netbox/extras/migrations/0014_configcontexts.py @@ -1,4 +1,4 @@ -# Generated by Django 2.0.6 on 2018-06-27 17:45 +# Generated by Django 2.0.6 on 2018-06-29 13:34 import django.contrib.postgres.fields.jsonb from django.db import migrations, models @@ -20,6 +20,7 @@ class Migration(migrations.Migration): ('name', models.CharField(max_length=100, unique=True)), ('weight', models.PositiveSmallIntegerField(default=1000)), ('is_active', models.BooleanField(default=True)), + ('description', models.CharField(blank=True, max_length=100)), ('data', django.contrib.postgres.fields.jsonb.JSONField()), ('platforms', models.ManyToManyField(blank=True, related_name='_configcontext_platforms_+', to='dcim.Platform')), ('regions', models.ManyToManyField(blank=True, related_name='_configcontext_regions_+', to='dcim.Region')), diff --git a/netbox/extras/models.py b/netbox/extras/models.py index c8822ff0d..f92693b11 100644 --- a/netbox/extras/models.py +++ b/netbox/extras/models.py @@ -646,6 +646,10 @@ class ConfigContext(models.Model): weight = models.PositiveSmallIntegerField( default=1000 ) + description = models.CharField( + max_length=100, + blank=True + ) is_active = models.BooleanField( default=True, ) diff --git a/netbox/extras/tables.py b/netbox/extras/tables.py index c22f2977b..4a7e987cb 100644 --- a/netbox/extras/tables.py +++ b/netbox/extras/tables.py @@ -70,7 +70,7 @@ class ConfigContextTable(BaseTable): class Meta(BaseTable.Meta): model = ConfigContext - fields = ('pk', 'name', 'weight', 'is_active') + fields = ('pk', 'name', 'weight', 'is_active', 'description', 'actions') class ObjectChangeTable(BaseTable): diff --git a/netbox/templates/extras/configcontext_edit.html b/netbox/templates/extras/configcontext_edit.html index a0f428131..4b7e53044 100644 --- a/netbox/templates/extras/configcontext_edit.html +++ b/netbox/templates/extras/configcontext_edit.html @@ -7,7 +7,13 @@
{% render_field form.name %} {% render_field form.weight %} + {% render_field form.description %} {% render_field form.is_active %} +
+ +
+
Assignment
+
{% render_field form.regions %} {% render_field form.sites %} {% render_field form.roles %} diff --git a/netbox/templates/extras/object_configcontext.html b/netbox/templates/extras/object_configcontext.html index a88cbde4d..5cc7e7d7f 100644 --- a/netbox/templates/extras/object_configcontext.html +++ b/netbox/templates/extras/object_configcontext.html @@ -26,6 +26,9 @@ {{ context.weight }}
{{ context.name }} + {% if context.description %} +
{{ context.description }} + {% endif %}
{{ context.data|render_json }}
{% endfor %}