ソースを参照

Rename Tag.comments to description

Jeremy Stretch 6 年 前
コミット
d4f6909859

+ 1 - 0
docs/release-notes/version-2.8.md

@@ -32,6 +32,7 @@ If further customization of remote authentication is desired (for instance, if y
 * dcim.Rack: The `/api/dcim/racks/<pk>/units/` endpoint has been replaced with `/api/dcim/racks/<pk>/elevation/`.
 * dcim.RackGroup: Added a `description` field
 * dcim.Region: Added a `description` field
+* extras.Tag: Renamed `comments` to `description`; truncated length to 200 characters; removed Markdown rendering
 * ipam.RIR: Added a `description` field
 * ipam.VLANGroup: Added a `description` field
 * tenancy.TenantGroup: Added a `description` field

+ 1 - 1
netbox/extras/api/serializers.py

@@ -91,7 +91,7 @@ class TagSerializer(ValidatedModelSerializer):
 
     class Meta:
         model = Tag
-        fields = ['id', 'name', 'slug', 'color', 'comments', 'tagged_items']
+        fields = ['id', 'name', 'slug', 'color', 'description', 'tagged_items']
 
 
 #

+ 6 - 3
netbox/extras/forms.py

@@ -144,12 +144,11 @@ class CustomFieldFilterForm(forms.Form):
 
 class TagForm(BootstrapMixin, forms.ModelForm):
     slug = SlugField()
-    comments = CommentField()
 
     class Meta:
         model = Tag
         fields = [
-            'name', 'slug', 'color', 'comments'
+            'name', 'slug', 'color', 'description'
         ]
 
 
@@ -181,9 +180,13 @@ class TagBulkEditForm(BootstrapMixin, BulkEditForm):
         required=False,
         widget=ColorSelect()
     )
+    description = forms.CharField(
+        max_length=200,
+        required=False
+    )
 
     class Meta:
-        nullable_fields = []
+        nullable_fields = ['description']
 
 
 #

+ 23 - 0
netbox/extras/migrations/0040_tag_description.py

@@ -0,0 +1,23 @@
+# Generated by Django 3.0.3 on 2020-03-13 20:46
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('extras', '0039_standardize_description'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='tag',
+            name='comments',
+            field=models.CharField(blank=True, max_length=200),
+        ),
+        migrations.RenameField(
+            model_name='tag',
+            old_name='comments',
+            new_name='description',
+        ),
+    ]

+ 2 - 2
netbox/extras/models.py

@@ -1051,9 +1051,9 @@ class Tag(TagBase, ChangeLoggedModel):
     color = ColorField(
         default='9e9e9e'
     )
-    comments = models.TextField(
+    description = models.CharField(
+        max_length=200,
         blank=True,
-        default=''
     )
 
     def get_absolute_url(self):

+ 1 - 1
netbox/extras/tables.py

@@ -77,7 +77,7 @@ class TagTable(BaseTable):
 
     class Meta(BaseTable.Meta):
         model = Tag
-        fields = ('pk', 'name', 'items', 'slug', 'color', 'actions')
+        fields = ('pk', 'name', 'items', 'slug', 'color', 'description', 'actions')
 
 
 class TaggedItemTable(BaseTable):

+ 5 - 12
netbox/templates/extras/tag.html

@@ -82,20 +82,13 @@
                             <span class="label color-block" style="background-color: #{{ tag.color }}">&nbsp;</span>
                         </td>
                     </tr>
+                    <tr>
+                        <td>Description</td>
+                        <td>
+                            {{ tag.description }}
+                        </td>
                 </table>
             </div>
-            <div class="panel panel-default">
-                <div class="panel-heading">
-                    <strong>Comments</strong>
-                </div>
-                <div class="panel-body rendered-markdown">
-                    {% if tag.comments %}
-                        {{ tag.comments|render_markdown }}
-                    {% else %}
-                        <span class="text-muted">None</span>
-                    {% endif %}
-                </div>
-            </div>
         </div>
         <div class="col-md-6">
             {% include 'panel_table.html' with table=items_table heading='Tagged Objects' %}

+ 1 - 6
netbox/templates/extras/tag_edit.html

@@ -8,12 +8,7 @@
             {% render_field form.name %}
             {% render_field form.slug %}
             {% render_field form.color %}
-        </div>
-    </div>
-    <div class="panel panel-default">
-        <div class="panel-heading"><strong>Comments</strong></div>
-        <div class="panel-body">
-            {% render_field form.comments %}
+            {% render_field form.description %}
         </div>
     </div>
 {% endblock %}