mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 12:12:53 -06:00
Closes #15547: Add comments field to CustomField model
This commit is contained in:
parent
824d66a54c
commit
0f0ab1a3be
@ -65,7 +65,7 @@ class CustomFieldSerializer(ValidatedModelSerializer):
|
|||||||
'id', 'url', 'display', 'object_types', 'type', 'related_object_type', 'data_type', 'name', 'label',
|
'id', 'url', 'display', 'object_types', 'type', 'related_object_type', 'data_type', 'name', 'label',
|
||||||
'group_name', 'description', 'required', 'search_weight', 'filter_logic', 'ui_visible', 'ui_editable',
|
'group_name', 'description', 'required', 'search_weight', 'filter_logic', 'ui_visible', 'ui_editable',
|
||||||
'is_cloneable', 'default', 'weight', 'validation_minimum', 'validation_maximum', 'validation_regex',
|
'is_cloneable', 'default', 'weight', 'validation_minimum', 'validation_maximum', 'validation_regex',
|
||||||
'choice_set', 'created', 'last_updated',
|
'choice_set', 'comments', 'created', 'last_updated',
|
||||||
]
|
]
|
||||||
brief_fields = ('id', 'url', 'display', 'name', 'description')
|
brief_fields = ('id', 'url', 'display', 'name', 'description')
|
||||||
|
|
||||||
|
@ -165,7 +165,8 @@ class CustomFieldFilterSet(ChangeLoggedModelFilterSet):
|
|||||||
Q(name__icontains=value) |
|
Q(name__icontains=value) |
|
||||||
Q(label__icontains=value) |
|
Q(label__icontains=value) |
|
||||||
Q(group_name__icontains=value) |
|
Q(group_name__icontains=value) |
|
||||||
Q(description__icontains=value)
|
Q(description__icontains=value) |
|
||||||
|
Q(comments__icontains=value)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from extras.choices import *
|
|||||||
from extras.models import *
|
from extras.models import *
|
||||||
from netbox.forms import NetBoxModelBulkEditForm
|
from netbox.forms import NetBoxModelBulkEditForm
|
||||||
from utilities.forms import BulkEditForm, add_blank_choice
|
from utilities.forms import BulkEditForm, add_blank_choice
|
||||||
from utilities.forms.fields import ColorField, DynamicModelChoiceField
|
from utilities.forms.fields import ColorField, CommentField, DynamicModelChoiceField
|
||||||
from utilities.forms.widgets import BulkEditNullBooleanSelect
|
from utilities.forms.widgets import BulkEditNullBooleanSelect
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
@ -64,6 +64,7 @@ class CustomFieldBulkEditForm(BulkEditForm):
|
|||||||
required=False,
|
required=False,
|
||||||
widget=BulkEditNullBooleanSelect()
|
widget=BulkEditNullBooleanSelect()
|
||||||
)
|
)
|
||||||
|
comments = CommentField()
|
||||||
|
|
||||||
nullable_fields = ('group_name', 'description', 'choice_set')
|
nullable_fields = ('group_name', 'description', 'choice_set')
|
||||||
|
|
||||||
@ -316,8 +317,4 @@ class JournalEntryBulkEditForm(BulkEditForm):
|
|||||||
choices=add_blank_choice(JournalEntryKindChoices),
|
choices=add_blank_choice(JournalEntryKindChoices),
|
||||||
required=False
|
required=False
|
||||||
)
|
)
|
||||||
comments = forms.CharField(
|
comments = CommentField()
|
||||||
label=_('Comments'),
|
|
||||||
required=False,
|
|
||||||
widget=forms.Textarea()
|
|
||||||
)
|
|
||||||
|
@ -71,7 +71,7 @@ class CustomFieldImportForm(CSVModelForm):
|
|||||||
fields = (
|
fields = (
|
||||||
'name', 'label', 'group_name', 'type', 'object_types', 'related_object_type', 'required', 'description',
|
'name', 'label', 'group_name', 'type', 'object_types', 'related_object_type', 'required', 'description',
|
||||||
'search_weight', 'filter_logic', 'default', 'choice_set', 'weight', 'validation_minimum',
|
'search_weight', 'filter_logic', 'default', 'choice_set', 'weight', 'validation_minimum',
|
||||||
'validation_maximum', 'validation_regex', 'ui_visible', 'ui_editable', 'is_cloneable',
|
'validation_maximum', 'validation_regex', 'ui_visible', 'ui_editable', 'is_cloneable', 'comments',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ class CustomFieldForm(forms.ModelForm):
|
|||||||
queryset=CustomFieldChoiceSet.objects.all(),
|
queryset=CustomFieldChoiceSet.objects.all(),
|
||||||
required=False
|
required=False
|
||||||
)
|
)
|
||||||
|
comments = CommentField()
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
FieldSet(
|
FieldSet(
|
||||||
|
18
netbox/extras/migrations/0114_customfield_add_comments.py
Normal file
18
netbox/extras/migrations/0114_customfield_add_comments.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.0.3 on 2024-04-19 18:37
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('extras', '0113_customfield_rename_object_type'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='customfield',
|
||||||
|
name='comments',
|
||||||
|
field=models.TextField(blank=True),
|
||||||
|
),
|
||||||
|
]
|
@ -205,6 +205,10 @@ class CustomField(CloningMixin, ExportTemplatesMixin, ChangeLoggedModel):
|
|||||||
verbose_name=_('is cloneable'),
|
verbose_name=_('is cloneable'),
|
||||||
help_text=_('Replicate this value when cloning objects')
|
help_text=_('Replicate this value when cloning objects')
|
||||||
)
|
)
|
||||||
|
comments = models.TextField(
|
||||||
|
verbose_name=_('comments'),
|
||||||
|
blank=True
|
||||||
|
)
|
||||||
|
|
||||||
objects = CustomFieldManager()
|
objects = CustomFieldManager()
|
||||||
|
|
||||||
|
@ -2,6 +2,18 @@ from netbox.search import SearchIndex, register_search
|
|||||||
from . import models
|
from . import models
|
||||||
|
|
||||||
|
|
||||||
|
@register_search
|
||||||
|
class CustomFieldIndex(SearchIndex):
|
||||||
|
model = models.CustomField
|
||||||
|
fields = (
|
||||||
|
('name', 100),
|
||||||
|
('label', 100),
|
||||||
|
('description', 500),
|
||||||
|
('comments', 5000),
|
||||||
|
)
|
||||||
|
display_attrs = ('description',)
|
||||||
|
|
||||||
|
|
||||||
@register_search
|
@register_search
|
||||||
class JournalEntryIndex(SearchIndex):
|
class JournalEntryIndex(SearchIndex):
|
||||||
model = models.JournalEntry
|
model = models.JournalEntry
|
||||||
|
@ -78,7 +78,7 @@ class CustomFieldTable(NetBoxTable):
|
|||||||
fields = (
|
fields = (
|
||||||
'pk', 'id', 'name', 'object_types', 'label', 'type', 'related_object_type', 'group_name', 'required',
|
'pk', 'id', 'name', 'object_types', 'label', 'type', 'related_object_type', 'group_name', 'required',
|
||||||
'default', 'description', 'search_weight', 'filter_logic', 'ui_visible', 'ui_editable', 'is_cloneable',
|
'default', 'description', 'search_weight', 'filter_logic', 'ui_visible', 'ui_editable', 'is_cloneable',
|
||||||
'weight', 'choice_set', 'choices', 'created', 'last_updated',
|
'weight', 'choice_set', 'choices', 'comments', 'created', 'last_updated',
|
||||||
)
|
)
|
||||||
default_columns = ('pk', 'name', 'object_types', 'label', 'group_name', 'type', 'required', 'description')
|
default_columns = ('pk', 'name', 'object_types', 'label', 'group_name', 'type', 'required', 'description')
|
||||||
|
|
||||||
|
@ -85,6 +85,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
{% include 'inc/panels/comments.html' %}
|
||||||
{% plugin_left_page object %}
|
{% plugin_left_page object %}
|
||||||
</div>
|
</div>
|
||||||
<div class="col col-md-6">
|
<div class="col col-md-6">
|
||||||
|
Loading…
Reference in New Issue
Block a user