fixed display bug installations detail, merged device/vm columns and added type for installations table view
This commit is contained in:
+2
-1
@@ -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/*
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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("<a href=\"{url}\">{count}</a>".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'}"
|
||||
|
||||
@@ -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}"
|
||||
|
||||
@@ -25,11 +25,7 @@
|
||||
<tr>
|
||||
<th scope="row">Installations</th>
|
||||
<td>
|
||||
<!-- {% for version in object.softwareproduct_versions.all %}-->
|
||||
<!-- <a href="{% url 'plugins:netbox_slm:softwareproductversion' pk=version.pk %}">-->
|
||||
<!-- <span class="badge" style="color: #ffffff; background-color: #9e9e9e">{{ version }}</span>-->
|
||||
<!-- </a>-->
|
||||
<!-- {% endfor %}-->
|
||||
{{ object.get_installation_count }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -78,9 +78,9 @@ class SoftwareProductVersionView(generic.ObjectView):
|
||||
|
||||
queryset = SoftwareProductVersion.objects.all()
|
||||
|
||||
# def get_extra_context(self, request, instance):
|
||||
# records = instance.record_set.all()
|
||||
# return {"records": records}
|
||||
def get_extra_context(self, request, instance):
|
||||
installation_count = instance.get_installation_count()
|
||||
return {"installations": installation_count}
|
||||
|
||||
|
||||
class SoftwareProductVersionEditView(generic.ObjectEditView):
|
||||
|
||||
@@ -16,7 +16,6 @@ classifiers =
|
||||
Programming Language :: Python
|
||||
Programming Language :: Python :: 3
|
||||
Programming Language :: Python :: 3 :: Only
|
||||
Programming Language :: Python :: 3.6
|
||||
Programming Language :: Python :: 3.7
|
||||
Programming Language :: Python :: 3.8
|
||||
Programming Language :: Python :: 3.9
|
||||
|
||||
Reference in New Issue
Block a user