diff --git a/src/README.rst b/src/README.rst index 557ceed..1b5dca3 100644 --- a/src/README.rst +++ b/src/README.rst @@ -20,7 +20,7 @@ to install the Netbox SLM plugin: 1. Add ``netbox_slm`` to the ``PLUGINS`` list in ``configuration/configuration.py``. -2. Create a ``plugin_requirements.txt`` with ``netbox-slm==0.9`` as +2. Create a ``plugin_requirements.txt`` with ``netbox-slm==0.93`` as contents. 3. Create a ``Dockerfile-SLM`` with contents: @@ -63,6 +63,7 @@ directory run :: + # make sure to update the version in netbox_slm/__init__.py $ python setup.py sdist $ twine upload dist/* diff --git a/src/netbox_slm/api/serializers.py b/src/netbox_slm/api/serializers.py index 05a4ec3..a214eae 100644 --- a/src/netbox_slm/api/serializers.py +++ b/src/netbox_slm/api/serializers.py @@ -21,7 +21,7 @@ class SoftwareProductSerializer(PrimaryModelSerializer): ] def get_display(self, obj): - return obj.name + return f"{obj.manufacturer.name} - {obj.name}" class SoftwareProductVersionSerializer(PrimaryModelSerializer): diff --git a/src/netbox_slm/models.py b/src/netbox_slm/models.py index 89449d7..941946b 100644 --- a/src/netbox_slm/models.py +++ b/src/netbox_slm/models.py @@ -55,6 +55,7 @@ class SoftwareProductVersion(PrimaryModel): return reverse("plugins:netbox_slm:softwareproductversion", kwargs={"pk": self.pk}) def get_installation_count(self): + print("ACCESSED") 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}", @@ -96,3 +97,9 @@ class SoftwareProductInstallation(PrimaryModel): def get_absolute_url(self): return reverse("plugins:netbox_slm:softwareproductinstallation", kwargs={"pk": self.pk}) + + def get_platform(self): + return self.device or self.virtualmachine + + def render_type(self): + return f"{'device' if self.device else 'virtualmachine'}" diff --git a/src/netbox_slm/tables.py b/src/netbox_slm/tables.py index 840d34c..379bf68 100644 --- a/src/netbox_slm/tables.py +++ b/src/netbox_slm/tables.py @@ -91,6 +91,11 @@ class SoftwareProductInstallationTable(BaseTable): accessor=Accessor('virtualmachine'), linkify=True ) + platform = tables.Column( + accessor='get_platform', + linkify=True + ) + type = tables.Column(accessor='render_type') software_product = tables.Column( accessor=Accessor('software_product'), linkify=True @@ -109,17 +114,20 @@ class SoftwareProductInstallationTable(BaseTable): fields = ( "pk", "name", - "device", - "virtualmachine", + "platform", + "type", "software_product", "version", # "tags", ) default_columns = ( "pk", - "device", - "virtualmachine", + "platform", + "type", "software_product", "version", # "tags", ) + + def render_software_product(self, value, **kwargs): + return f"{kwargs['record'].software_product.manufacturer.name} - {value}" diff --git a/src/netbox_slm/templates/netbox_slm/softwareproductversion.html b/src/netbox_slm/templates/netbox_slm/softwareproductversion.html index 6853b61..ed5db57 100644 --- a/src/netbox_slm/templates/netbox_slm/softwareproductversion.html +++ b/src/netbox_slm/templates/netbox_slm/softwareproductversion.html @@ -25,11 +25,7 @@