Просмотр исходного кода

Closes #2898: Enable filtering cables list by connection status

Jeremy Stretch 7 лет назад
Родитель
Сommit
fba154386e
4 измененных файлов с 12 добавлено и 0 удалено
  1. 1 0
      CHANGELOG.md
  2. 5 0
      netbox/dcim/forms.py
  3. 3 0
      netbox/dcim/models.py
  4. 3 0
      netbox/dcim/tables.py

+ 1 - 0
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
 * [#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
 * [#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
 * [#2903](https://github.com/digitalocean/netbox/issues/2903) - Clarify purpose of tags field on interface edit form
 
 
 ## Bug Fixes
 ## Bug Fixes

+ 5 - 0
netbox/dcim/forms.py

@@ -2757,6 +2757,11 @@ class CableFilterForm(BootstrapMixin, forms.Form):
         required=False,
         required=False,
         widget=StaticSelect2()
         widget=StaticSelect2()
     )
     )
+    status = forms.ChoiceField(
+        required=False,
+        choices=add_blank_choice(CONNECTION_STATUS_CHOICES),
+        widget=StaticSelect2()
+    )
     color = forms.CharField(
     color = forms.CharField(
         max_length=6,
         max_length=6,
         required=False,
         required=False,

+ 3 - 0
netbox/dcim/models.py

@@ -2651,6 +2651,9 @@ class Cable(ChangeLoggedModel):
             self.length_unit,
             self.length_unit,
         )
         )
 
 
+    def get_status_class(self):
+        return 'success' if self.status else 'info'
+
     def get_path_endpoints(self):
     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
         Traverse both ends of a cable path and return its connected endpoints. Note that one or both endpoints may be

+ 3 - 0
netbox/dcim/tables.py

@@ -647,6 +647,9 @@ class CableTable(BaseTable):
         orderable=False,
         orderable=False,
         verbose_name=''
         verbose_name=''
     )
     )
+    status = tables.TemplateColumn(
+        template_code=STATUS_LABEL
+    )
     length = tables.TemplateColumn(
     length = tables.TemplateColumn(
         template_code=CABLE_LENGTH,
         template_code=CABLE_LENGTH,
         order_by='_abs_length'
         order_by='_abs_length'