Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #2643: Add description field to console/power components and device bays #2918

Merged
merged 1 commit into from
Feb 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ the Config Context from being included in any results.
## Enhancements

* [#2324](https://github.com/digitalocean/netbox/issues/2324) - Add color option for tags
* [#2643](https://github.com/digitalocean/netbox/issues/2643) - Add `description` field to console/power components and device bays
* [#2791](https://github.com/digitalocean/netbox/issues/2791) - Add a comment field for tags

---
Expand Down
18 changes: 9 additions & 9 deletions netbox/dcim/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ class ConsoleServerPortSerializer(TaggitSerializer, ConnectedEndpointSerializer)
class Meta:
model = ConsoleServerPort
fields = [
'id', 'device', 'name', 'connected_endpoint_type', 'connected_endpoint', 'connection_status', 'cable',
'tags',
'id', 'device', 'name', 'description', 'connected_endpoint_type', 'connected_endpoint', 'connection_status',
'cable', 'tags',
]


Expand All @@ -359,8 +359,8 @@ class ConsolePortSerializer(TaggitSerializer, ConnectedEndpointSerializer):
class Meta:
model = ConsolePort
fields = [
'id', 'device', 'name', 'connected_endpoint_type', 'connected_endpoint', 'connection_status', 'cable',
'tags',
'id', 'device', 'name', 'description', 'connected_endpoint_type', 'connected_endpoint', 'connection_status',
'cable', 'tags',
]


Expand All @@ -372,8 +372,8 @@ class PowerOutletSerializer(TaggitSerializer, ConnectedEndpointSerializer):
class Meta:
model = PowerOutlet
fields = [
'id', 'device', 'name', 'connected_endpoint_type', 'connected_endpoint', 'connection_status', 'cable',
'tags',
'id', 'device', 'name', 'description', 'connected_endpoint_type', 'connected_endpoint', 'connection_status',
'cable', 'tags',
]


Expand All @@ -385,8 +385,8 @@ class PowerPortSerializer(TaggitSerializer, ConnectedEndpointSerializer):
class Meta:
model = PowerPort
fields = [
'id', 'device', 'name', 'connected_endpoint_type', 'connected_endpoint', 'connection_status', 'cable',
'tags',
'id', 'device', 'name', 'description', 'connected_endpoint_type', 'connected_endpoint', 'connection_status',
'cable', 'tags',
]


Expand Down Expand Up @@ -475,7 +475,7 @@ class DeviceBaySerializer(TaggitSerializer, ValidatedModelSerializer):

class Meta:
model = DeviceBay
fields = ['id', 'device', 'name', 'installed_device', 'tags']
fields = ['id', 'device', 'name', 'description', 'installed_device', 'tags']


#
Expand Down
22 changes: 12 additions & 10 deletions netbox/dcim/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,8 @@ def search(self, queryset, name, value):
if not value.strip():
return queryset
return queryset.filter(
Q(name__icontains=value)
Q(name__icontains=value) |
Q(description__icontains=value)
)


Expand All @@ -702,7 +703,7 @@ class ConsolePortFilter(DeviceComponentFilterSet):

class Meta:
model = ConsolePort
fields = ['name', 'connection_status']
fields = ['name', 'description', 'connection_status']


class ConsoleServerPortFilter(DeviceComponentFilterSet):
Expand All @@ -714,7 +715,7 @@ class ConsoleServerPortFilter(DeviceComponentFilterSet):

class Meta:
model = ConsoleServerPort
fields = ['name', 'connection_status']
fields = ['name', 'description', 'connection_status']


class PowerPortFilter(DeviceComponentFilterSet):
Expand All @@ -726,7 +727,7 @@ class PowerPortFilter(DeviceComponentFilterSet):

class Meta:
model = PowerPort
fields = ['name', 'connection_status']
fields = ['name', 'description', 'connection_status']


class PowerOutletFilter(DeviceComponentFilterSet):
Expand All @@ -738,7 +739,7 @@ class PowerOutletFilter(DeviceComponentFilterSet):

class Meta:
model = PowerOutlet
fields = ['name', 'connection_status']
fields = ['name', 'description', 'connection_status']


class InterfaceFilter(django_filters.FilterSet):
Expand Down Expand Up @@ -793,13 +794,14 @@ class InterfaceFilter(django_filters.FilterSet):

class Meta:
model = Interface
fields = ['name', 'connection_status', 'form_factor', 'enabled', 'mtu', 'mgmt_only']
fields = ['name', 'connection_status', 'form_factor', 'enabled', 'mtu', 'mgmt_only', 'description']

def search(self, queryset, name, value):
if not value.strip():
return queryset
return queryset.filter(
Q(name__icontains=value)
Q(name__icontains=value) |
Q(description__icontains=value)
).distinct()

def filter_device(self, queryset, name, value):
Expand Down Expand Up @@ -857,7 +859,7 @@ class FrontPortFilter(DeviceComponentFilterSet):

class Meta:
model = FrontPort
fields = ['name', 'type']
fields = ['name', 'type', 'description']


class RearPortFilter(DeviceComponentFilterSet):
Expand All @@ -869,14 +871,14 @@ class RearPortFilter(DeviceComponentFilterSet):

class Meta:
model = RearPort
fields = ['name', 'type']
fields = ['name', 'type', 'description']


class DeviceBayFilter(DeviceComponentFilterSet):

class Meta:
model = DeviceBay
fields = ['name']
fields = ['name', 'description']


class InventoryItemFilter(DeviceComponentFilterSet):
Expand Down
58 changes: 53 additions & 5 deletions netbox/dcim/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1854,7 +1854,7 @@ class ConsolePortForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = ConsolePort
fields = [
'device', 'name', 'tags',
'device', 'name', 'description', 'tags',
]
widgets = {
'device': forms.HiddenInput(),
Expand All @@ -1865,6 +1865,10 @@ class ConsolePortCreateForm(ComponentForm):
name_pattern = ExpandableNameField(
label='Name'
)
description = forms.CharField(
max_length=100,
required=False
)
tags = TagField(
required=False
)
Expand All @@ -1882,7 +1886,7 @@ class ConsoleServerPortForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = ConsoleServerPort
fields = [
'device', 'name', 'tags',
'device', 'name', 'description', 'tags',
]
widgets = {
'device': forms.HiddenInput(),
Expand All @@ -1893,11 +1897,31 @@ class ConsoleServerPortCreateForm(ComponentForm):
name_pattern = ExpandableNameField(
label='Name'
)
description = forms.CharField(
max_length=100,
required=False
)
tags = TagField(
required=False
)


class ConsoleServerPortBulkEditForm(BootstrapMixin, AddRemoveTagsForm, BulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=ConsoleServerPort.objects.all(),
widget=forms.MultipleHiddenInput()
)
description = forms.CharField(
max_length=100,
required=False
)

class Meta:
nullable_fields = [
'description',
]


class ConsoleServerPortBulkRenameForm(BulkRenameForm):
pk = forms.ModelMultipleChoiceField(
queryset=ConsoleServerPort.objects.all(),
Expand All @@ -1924,7 +1948,7 @@ class PowerPortForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = PowerPort
fields = [
'device', 'name', 'tags',
'device', 'name', 'description', 'tags',
]
widgets = {
'device': forms.HiddenInput(),
Expand All @@ -1935,6 +1959,10 @@ class PowerPortCreateForm(ComponentForm):
name_pattern = ExpandableNameField(
label='Name'
)
description = forms.CharField(
max_length=100,
required=False
)
tags = TagField(
required=False
)
Expand All @@ -1952,7 +1980,7 @@ class PowerOutletForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = PowerOutlet
fields = [
'device', 'name', 'tags',
'device', 'name', 'description', 'tags',
]
widgets = {
'device': forms.HiddenInput(),
Expand All @@ -1963,11 +1991,31 @@ class PowerOutletCreateForm(ComponentForm):
name_pattern = ExpandableNameField(
label='Name'
)
description = forms.CharField(
max_length=100,
required=False
)
tags = TagField(
required=False
)


class PowerOutletBulkEditForm(BootstrapMixin, AddRemoveTagsForm, BulkEditForm):
pk = forms.ModelMultipleChoiceField(
queryset=PowerOutlet.objects.all(),
widget=forms.MultipleHiddenInput()
)
description = forms.CharField(
max_length=100,
required=False
)

class Meta:
nullable_fields = [
'description',
]


class PowerOutletBulkRenameForm(BulkRenameForm):
pk = forms.ModelMultipleChoiceField(
queryset=PowerOutlet.objects.all(),
Expand Down Expand Up @@ -2776,7 +2824,7 @@ class DeviceBayForm(BootstrapMixin, forms.ModelForm):
class Meta:
model = DeviceBay
fields = [
'device', 'name', 'tags',
'device', 'name', 'description', 'tags',
]
widgets = {
'device': forms.HiddenInput(),
Expand Down
38 changes: 38 additions & 0 deletions netbox/dcim/migrations/0071_device_components_add_description.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 2.1.7 on 2019-02-20 18:50

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('dcim', '0070_custom_tag_models'),
]

operations = [
migrations.AddField(
model_name='consoleport',
name='description',
field=models.CharField(blank=True, max_length=100),
),
migrations.AddField(
model_name='consoleserverport',
name='description',
field=models.CharField(blank=True, max_length=100),
),
migrations.AddField(
model_name='devicebay',
name='description',
field=models.CharField(blank=True, max_length=100),
),
migrations.AddField(
model_name='poweroutlet',
name='description',
field=models.CharField(blank=True, max_length=100),
),
migrations.AddField(
model_name='powerport',
name='description',
field=models.CharField(blank=True, max_length=100),
),
]
Loading