From d5bdc3f56707bf0dba47ed77442422933754993e Mon Sep 17 00:00:00 2001 From: Sergey Tokarenko Date: Tue, 4 Jan 2022 01:28:10 +0200 Subject: [PATCH] feat: Ability to do global search by tag --- netbox/netbox/constants.py | 10 ++++++++++ netbox/netbox/forms.py | 3 +++ 2 files changed, 13 insertions(+) diff --git a/netbox/netbox/constants.py b/netbox/netbox/constants.py index 3e935e722..7cbfb031b 100644 --- a/netbox/netbox/constants.py +++ b/netbox/netbox/constants.py @@ -22,6 +22,9 @@ from utilities.utils import count_related from virtualization.filtersets import ClusterFilterSet, VirtualMachineFilterSet from virtualization.models import Cluster, VirtualMachine from virtualization.tables import ClusterTable, VirtualMachineTable +from extras.filtersets import TagFilterSet +from extras.models import Tag +from extras.tables import TagTable SEARCH_MAX_RESULTS = 15 SEARCH_TYPES = OrderedDict(( @@ -177,4 +180,11 @@ SEARCH_TYPES = OrderedDict(( 'table': TenantTable, 'url': 'tenancy:tenant_list', }), + # Other + ('tag', { + 'queryset': Tag.objects.prefetch_related('prefix'), + 'filterset': TagFilterSet, + 'table': TagTable, + 'url': 'extras:tag_list', + }), )) diff --git a/netbox/netbox/forms.py b/netbox/netbox/forms.py index b5d68c1fc..8942e8e0f 100644 --- a/netbox/netbox/forms.py +++ b/netbox/netbox/forms.py @@ -33,6 +33,9 @@ OBJ_TYPE_CHOICES = ( ('cluster', 'Clusters'), ('virtualmachine', 'Virtual Machines'), )), + ('Other', ( + ('tag', 'Tags'), + )), )