From d4f6909859a5f32e49329c484ea730fb455714d1 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 13 Mar 2020 17:00:00 -0400 Subject: [PATCH] Rename Tag.comments to description --- docs/release-notes/version-2.8.md | 1 + netbox/extras/api/serializers.py | 2 +- netbox/extras/forms.py | 9 +++++--- .../extras/migrations/0040_tag_description.py | 23 +++++++++++++++++++ netbox/extras/models.py | 4 ++-- netbox/extras/tables.py | 2 +- netbox/templates/extras/tag.html | 17 ++++---------- netbox/templates/extras/tag_edit.html | 7 +----- 8 files changed, 40 insertions(+), 25 deletions(-) create mode 100644 netbox/extras/migrations/0040_tag_description.py diff --git a/docs/release-notes/version-2.8.md b/docs/release-notes/version-2.8.md index 2473de067..f42625ef2 100644 --- a/docs/release-notes/version-2.8.md +++ b/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//units/` endpoint has been replaced with `/api/dcim/racks//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 diff --git a/netbox/extras/api/serializers.py b/netbox/extras/api/serializers.py index 40606ed8e..f3c05d37e 100644 --- a/netbox/extras/api/serializers.py +++ b/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'] # diff --git a/netbox/extras/forms.py b/netbox/extras/forms.py index b792ec484..85d19756a 100644 --- a/netbox/extras/forms.py +++ b/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'] # diff --git a/netbox/extras/migrations/0040_tag_description.py b/netbox/extras/migrations/0040_tag_description.py new file mode 100644 index 000000000..9d17b205f --- /dev/null +++ b/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', + ), + ] diff --git a/netbox/extras/models.py b/netbox/extras/models.py index 0de5ec8e5..33b25685c 100644 --- a/netbox/extras/models.py +++ b/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): diff --git a/netbox/extras/tables.py b/netbox/extras/tables.py index 08c5ed471..b145824c6 100644 --- a/netbox/extras/tables.py +++ b/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): diff --git a/netbox/templates/extras/tag.html b/netbox/templates/extras/tag.html index 64e5bbebd..d87aec3f7 100644 --- a/netbox/templates/extras/tag.html +++ b/netbox/templates/extras/tag.html @@ -82,20 +82,13 @@   + + Description + + {{ tag.description }} + -
-
- Comments -
-
- {% if tag.comments %} - {{ tag.comments|render_markdown }} - {% else %} - None - {% endif %} -
-
{% include 'panel_table.html' with table=items_table heading='Tagged Objects' %} diff --git a/netbox/templates/extras/tag_edit.html b/netbox/templates/extras/tag_edit.html index 800db1d26..87b9a2e53 100644 --- a/netbox/templates/extras/tag_edit.html +++ b/netbox/templates/extras/tag_edit.html @@ -8,12 +8,7 @@ {% render_field form.name %} {% render_field form.slug %} {% render_field form.color %} -
- -
-
Comments
-
- {% render_field form.comments %} + {% render_field form.description %}
{% endblock %}