From fba154386ece22e68b4236aad539e5db44c6a7e3 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 20 Feb 2019 11:36:55 -0500 Subject: [PATCH] Closes #2898: Enable filtering cables list by connection status --- CHANGELOG.md | 1 + netbox/dcim/forms.py | 5 +++++ netbox/dcim/models.py | 3 +++ netbox/dcim/tables.py | 3 +++ 4 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 839116a31..311e1aa3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ v2.5.7 (FUTURE) * [#2357](https://github.com/digitalocean/netbox/issues/2357) - Enable filtering of devices by rack face * [#2878](https://github.com/digitalocean/netbox/issues/2878) - Add cable types for OS1/OS2 singlemode fiber +* [#2898](https://github.com/digitalocean/netbox/issues/2898) - Enable filtering cables list by connection status * [#2903](https://github.com/digitalocean/netbox/issues/2903) - Clarify purpose of tags field on interface edit form ## Bug Fixes diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py index 44e61db2d..ad209c516 100644 --- a/netbox/dcim/forms.py +++ b/netbox/dcim/forms.py @@ -2757,6 +2757,11 @@ class CableFilterForm(BootstrapMixin, forms.Form): required=False, widget=StaticSelect2() ) + status = forms.ChoiceField( + required=False, + choices=add_blank_choice(CONNECTION_STATUS_CHOICES), + widget=StaticSelect2() + ) color = forms.CharField( max_length=6, required=False, diff --git a/netbox/dcim/models.py b/netbox/dcim/models.py index f7892b2af..49879beb1 100644 --- a/netbox/dcim/models.py +++ b/netbox/dcim/models.py @@ -2651,6 +2651,9 @@ class Cable(ChangeLoggedModel): self.length_unit, ) + def get_status_class(self): + return 'success' if self.status else 'info' + def get_path_endpoints(self): """ Traverse both ends of a cable path and return its connected endpoints. Note that one or both endpoints may be diff --git a/netbox/dcim/tables.py b/netbox/dcim/tables.py index 3cbd9378d..5649c10ef 100644 --- a/netbox/dcim/tables.py +++ b/netbox/dcim/tables.py @@ -647,6 +647,9 @@ class CableTable(BaseTable): orderable=False, verbose_name='' ) + status = tables.TemplateColumn( + template_code=STATUS_LABEL + ) length = tables.TemplateColumn( template_code=CABLE_LENGTH, order_by='_abs_length'