Просмотр исходного кода

Added description to ConfigContext

Jeremy Stretch 7 лет назад
Родитель
Сommit
743cf6d398

+ 3 - 1
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',
+        ]
 
 
 #

+ 3 - 1
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',
+        ]
 
 
 #

+ 2 - 1
netbox/extras/migrations/0014_config-contexts.py → 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')),

+ 4 - 0
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,
     )

+ 1 - 1
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):

+ 6 - 0
netbox/templates/extras/configcontext_edit.html

@@ -7,7 +7,13 @@
         <div class="panel-body">
             {% render_field form.name %}
             {% render_field form.weight %}
+            {% render_field form.description %}
             {% render_field form.is_active %}
+        </div>
+    </div>
+    <div class="panel panel-default">
+        <div class="panel-heading"><strong>Assignment</strong></div>
+        <div class="panel-body">
             {% render_field form.regions %}
             {% render_field form.sites %}
             {% render_field form.roles %}

+ 3 - 0
netbox/templates/extras/object_configcontext.html

@@ -26,6 +26,9 @@
                             <span class="text-muted">{{ context.weight }}</span>
                         </div>
                         <a href="{{ context.get_absolute_url }}"><strong>{{ context.name }}</strong></a>
+                        {% if context.description %}
+                            <br /><small>{{ context.description }}</small>
+                        {% endif %}
                         <pre>{{ context.data|render_json }}</pre>
                     </div>
                 {% endfor %}