diff --git a/src/netbox_slm/filters.py b/src/netbox_slm/filters.py
index 3a56901..b8633dd 100644
--- a/src/netbox_slm/filters.py
+++ b/src/netbox_slm/filters.py
@@ -66,3 +66,10 @@ class SoftwareProductInstallationFilter(BaseFilter):
class Meta:
model = SoftwareProductInstallation
fields = tuple() # "tag")
+
+ def search(self, queryset, name, value):
+ """Perform the filtered search."""
+ if not value.strip():
+ return queryset
+ qs_filter = Q(software_product__name__icontains=value) | Q(version__name__icontains=value)
+ return queryset.filter(qs_filter)
diff --git a/src/netbox_slm/models.py b/src/netbox_slm/models.py
index f14365a..f2fb592 100644
--- a/src/netbox_slm/models.py
+++ b/src/netbox_slm/models.py
@@ -1,5 +1,6 @@
from django.db import models
-from django.urls import reverse
+from django.urls import reverse, reverse_lazy
+from django.utils import safestring
from extras.utils import extras_features
from netbox.models import PrimaryModel
from utilities.querysets import RestrictedQuerySet
@@ -28,7 +29,11 @@ class SoftwareProduct(PrimaryModel):
return reverse("plugins:netbox_slm:softwareproduct", kwargs={"pk": self.pk})
def get_installation_count(self):
- return SoftwareProductInstallation.objects.filter(software_product_id=self.pk).count()
+ count = SoftwareProductInstallation.objects.filter(software_product_id=self.pk).count()
+ return safestring.mark_safe("{count}".format(
+ url=reverse_lazy("plugins:netbox_slm:softwareproductinstallation_list") + f"?q={self.name}",
+ count=count
+ )) if count else "0"
# @extras_features('custom_fields', 'custom_links', 'export_templates', 'tags', 'webhooks')
@@ -49,7 +54,11 @@ class SoftwareProductVersion(PrimaryModel):
return reverse("plugins:netbox_slm:softwareproductversion", kwargs={"pk": self.pk})
def get_installation_count(self):
- return SoftwareProductInstallation.objects.filter(version_id=self.pk).count()
+ count = SoftwareProductInstallation.objects.filter(version_id=self.pk).count()
+ return safestring.mark_safe("{count}".format(
+ url=reverse_lazy("plugins:netbox_slm:softwareproductinstallation_list") + f"?q={self.name}",
+ count=count
+ )) if count else "0"
# @extras_features('custom_fields', 'custom_links', 'export_templates', 'tags', 'webhooks')