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
|
1. Add ``netbox_slm`` to the ``PLUGINS`` list in
|
||||||
``configuration/configuration.py``.
|
``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.
|
contents.
|
||||||
3. Create a ``Dockerfile-SLM`` with 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
|
$ python setup.py sdist
|
||||||
$ twine upload dist/*
|
$ twine upload dist/*
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class SoftwareProductSerializer(PrimaryModelSerializer):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def get_display(self, obj):
|
def get_display(self, obj):
|
||||||
return obj.name
|
return f"{obj.manufacturer.name} - {obj.name}"
|
||||||
|
|
||||||
|
|
||||||
class SoftwareProductVersionSerializer(PrimaryModelSerializer):
|
class SoftwareProductVersionSerializer(PrimaryModelSerializer):
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ class SoftwareProductVersion(PrimaryModel):
|
|||||||
return reverse("plugins:netbox_slm:softwareproductversion", kwargs={"pk": self.pk})
|
return reverse("plugins:netbox_slm:softwareproductversion", kwargs={"pk": self.pk})
|
||||||
|
|
||||||
def get_installation_count(self):
|
def get_installation_count(self):
|
||||||
|
print("ACCESSED")
|
||||||
count = SoftwareProductInstallation.objects.filter(version_id=self.pk).count()
|
count = SoftwareProductInstallation.objects.filter(version_id=self.pk).count()
|
||||||
return safestring.mark_safe("<a href=\"{url}\">{count}</a>".format(
|
return safestring.mark_safe("<a href=\"{url}\">{count}</a>".format(
|
||||||
url=reverse_lazy("plugins:netbox_slm:softwareproductinstallation_list") + f"?q={self.name}",
|
url=reverse_lazy("plugins:netbox_slm:softwareproductinstallation_list") + f"?q={self.name}",
|
||||||
@@ -96,3 +97,9 @@ class SoftwareProductInstallation(PrimaryModel):
|
|||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse("plugins:netbox_slm:softwareproductinstallation", kwargs={"pk": self.pk})
|
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'),
|
accessor=Accessor('virtualmachine'),
|
||||||
linkify=True
|
linkify=True
|
||||||
)
|
)
|
||||||
|
platform = tables.Column(
|
||||||
|
accessor='get_platform',
|
||||||
|
linkify=True
|
||||||
|
)
|
||||||
|
type = tables.Column(accessor='render_type')
|
||||||
software_product = tables.Column(
|
software_product = tables.Column(
|
||||||
accessor=Accessor('software_product'),
|
accessor=Accessor('software_product'),
|
||||||
linkify=True
|
linkify=True
|
||||||
@@ -109,17 +114,20 @@ class SoftwareProductInstallationTable(BaseTable):
|
|||||||
fields = (
|
fields = (
|
||||||
"pk",
|
"pk",
|
||||||
"name",
|
"name",
|
||||||
"device",
|
"platform",
|
||||||
"virtualmachine",
|
"type",
|
||||||
"software_product",
|
"software_product",
|
||||||
"version",
|
"version",
|
||||||
# "tags",
|
# "tags",
|
||||||
)
|
)
|
||||||
default_columns = (
|
default_columns = (
|
||||||
"pk",
|
"pk",
|
||||||
"device",
|
"platform",
|
||||||
"virtualmachine",
|
"type",
|
||||||
"software_product",
|
"software_product",
|
||||||
"version",
|
"version",
|
||||||
# "tags",
|
# "tags",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def render_software_product(self, value, **kwargs):
|
||||||
|
return f"{kwargs['record'].software_product.manufacturer.name} - {value}"
|
||||||
|
|||||||
@@ -25,11 +25,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Installations</th>
|
<th scope="row">Installations</th>
|
||||||
<td>
|
<td>
|
||||||
<!-- {% for version in object.softwareproduct_versions.all %}-->
|
{{ object.get_installation_count }}
|
||||||
<!-- <a href="{% url 'plugins:netbox_slm:softwareproductversion' pk=version.pk %}">-->
|
|
||||||
<!-- <span class="badge" style="color: #ffffff; background-color: #9e9e9e">{{ version }}</span>-->
|
|
||||||
<!-- </a>-->
|
|
||||||
<!-- {% endfor %}-->
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -78,9 +78,9 @@ class SoftwareProductVersionView(generic.ObjectView):
|
|||||||
|
|
||||||
queryset = SoftwareProductVersion.objects.all()
|
queryset = SoftwareProductVersion.objects.all()
|
||||||
|
|
||||||
# def get_extra_context(self, request, instance):
|
def get_extra_context(self, request, instance):
|
||||||
# records = instance.record_set.all()
|
installation_count = instance.get_installation_count()
|
||||||
# return {"records": records}
|
return {"installations": installation_count}
|
||||||
|
|
||||||
|
|
||||||
class SoftwareProductVersionEditView(generic.ObjectEditView):
|
class SoftwareProductVersionEditView(generic.ObjectEditView):
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ classifiers =
|
|||||||
Programming Language :: Python
|
Programming Language :: Python
|
||||||
Programming Language :: Python :: 3
|
Programming Language :: Python :: 3
|
||||||
Programming Language :: Python :: 3 :: Only
|
Programming Language :: Python :: 3 :: Only
|
||||||
Programming Language :: Python :: 3.6
|
|
||||||
Programming Language :: Python :: 3.7
|
Programming Language :: Python :: 3.7
|
||||||
Programming Language :: Python :: 3.8
|
Programming Language :: Python :: 3.8
|
||||||
Programming Language :: Python :: 3.9
|
Programming Language :: Python :: 3.9
|
||||||
|
|||||||
Reference in New Issue
Block a user