Prepare for upgrade to NetBox v4.0.6 (#40)

Closes #38
This commit is contained in:
wkoot
2024-07-09 22:15:58 +02:00
committed by GitHub
parent 230b3b5115
commit 86215f43a6
18 changed files with 179 additions and 216 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
from extras.plugins import PluginConfig
from netbox.plugins import PluginConfig
__version__ = "1.6.0"
+12 -8
View File
@@ -10,7 +10,7 @@ class SoftwareLicenseSerializer(NetBoxModelSerializer):
class Meta:
model = SoftwareLicense
fields = [
fields = (
"id",
"display",
"url",
@@ -31,7 +31,8 @@ class SoftwareLicenseSerializer(NetBoxModelSerializer):
"custom_field_data",
"created",
"last_updated",
]
)
brief_fields = ("id", "display", "url", "name", "description")
def get_display(self, obj):
return f"{obj}"
@@ -43,7 +44,7 @@ class SoftwareProductSerializer(NetBoxModelSerializer):
class Meta:
model = SoftwareProduct
fields = [
fields = (
"id",
"display",
"url",
@@ -55,7 +56,8 @@ class SoftwareProductSerializer(NetBoxModelSerializer):
"custom_field_data",
"created",
"last_updated",
]
)
brief_fields = ("id", "display", "url", "name", "description")
def get_display(self, obj):
return f"{obj.manufacturer} - {obj}"
@@ -69,7 +71,7 @@ class SoftwareProductInstallationSerializer(NetBoxModelSerializer):
class Meta:
model = SoftwareProductInstallation
fields = [
fields = (
"id",
"display",
"url",
@@ -83,7 +85,8 @@ class SoftwareProductInstallationSerializer(NetBoxModelSerializer):
"custom_field_data",
"created",
"last_updated",
]
)
brief_fields = ("id", "display", "url", "name")
def get_display(self, obj):
return f"{obj}"
@@ -95,7 +98,7 @@ class SoftwareProductVersionSerializer(NetBoxModelSerializer):
class Meta:
model = SoftwareProductVersion
fields = [
fields = (
"id",
"display",
"url",
@@ -113,7 +116,8 @@ class SoftwareProductVersionSerializer(NetBoxModelSerializer):
"custom_field_data",
"created",
"last_updated",
]
)
brief_fields = ("id", "display", "url", "name")
def get_display(self, obj):
return f"{obj}"
+3 -11
View File
@@ -4,6 +4,7 @@ from django.urls import reverse_lazy
from netbox.forms import NetBoxModelForm, NetBoxModelImportForm, NetBoxModelBulkEditForm, NetBoxModelFilterSetForm
from netbox_slm.models import SoftwareProduct, SoftwareProductVersion, SoftwareProductInstallation, SoftwareLicense
from utilities.forms.fields import CommentField, DynamicModelChoiceField, TagFilterField, LaxURLField
from utilities.forms.rendering import FieldSet
from utilities.forms.widgets import APISelect, DatePicker
@@ -62,7 +63,7 @@ class SoftwareLicenseForm(NetBoxModelForm):
class SoftwareLicenseFilterForm(NetBoxModelFilterSetForm):
model = SoftwareLicense
fieldsets = ((None, ("q", "tag")),)
fieldsets = (FieldSet(None, ("q", "tag")),)
tag = TagFilterField(model)
@@ -85,13 +86,4 @@ class SoftwareLicenseBulkEditForm(NetBoxModelBulkEditForm):
version = DynamicModelChoiceField(queryset=SoftwareProductVersion.objects.all(), required=False)
installation = DynamicModelChoiceField(queryset=SoftwareProductInstallation.objects.all(), required=False)
model = SoftwareLicense
fieldsets = (
(
None,
(
"software_product",
"version",
"installation",
),
),
)
fieldsets = (FieldSet(None, ("software_product", "version", "installation")),)
+2 -1
View File
@@ -4,6 +4,7 @@ from dcim.models import Manufacturer
from netbox.forms import NetBoxModelForm, NetBoxModelImportForm, NetBoxModelBulkEditForm, NetBoxModelFilterSetForm
from netbox_slm.models import SoftwareProduct
from utilities.forms.fields import CommentField, DynamicModelChoiceField, TagFilterField
from utilities.forms.rendering import FieldSet
class SoftwareProductForm(NetBoxModelForm):
@@ -29,7 +30,7 @@ class SoftwareProductForm(NetBoxModelForm):
class SoftwareProductFilterForm(NetBoxModelFilterSetForm):
model = SoftwareProduct
fieldsets = ((None, ("q", "tag")),)
fieldsets = (FieldSet(None, ("q", "tag")),)
tag = TagFilterField(model)
@@ -5,6 +5,7 @@ from dcim.models import Device
from netbox.forms import NetBoxModelForm, NetBoxModelImportForm, NetBoxModelBulkEditForm, NetBoxModelFilterSetForm
from netbox_slm.models import SoftwareProductInstallation, SoftwareProduct, SoftwareProductVersion
from utilities.forms.fields import CommentField, DynamicModelChoiceField, TagFilterField
from utilities.forms.rendering import FieldSet
from utilities.forms.widgets import APISelect
from virtualization.models import VirtualMachine, Cluster
@@ -56,7 +57,7 @@ class SoftwareProductInstallationForm(NetBoxModelForm):
class SoftwareProductInstallationFilterForm(NetBoxModelFilterSetForm):
model = SoftwareProductInstallation
fieldsets = ((None, ("q", "tag")),)
fieldsets = (FieldSet(None, ("q", "tag")),)
tag = TagFilterField(model)
@@ -70,12 +71,4 @@ class SoftwareProductInstallationBulkEditForm(NetBoxModelBulkEditForm):
software_product = DynamicModelChoiceField(queryset=SoftwareProduct.objects.all(), required=False)
version = DynamicModelChoiceField(queryset=SoftwareProductVersion.objects.all(), required=False)
model = SoftwareProductInstallation
fieldsets = (
(
None,
(
"software_product",
"version",
),
),
)
fieldsets = (FieldSet(None, ("software_product", "version")),)
+2 -1
View File
@@ -4,6 +4,7 @@ from django.urls import reverse_lazy
from netbox.forms import NetBoxModelForm, NetBoxModelImportForm, NetBoxModelBulkEditForm, NetBoxModelFilterSetForm
from netbox_slm.models import SoftwareProduct, SoftwareProductVersion
from utilities.forms.fields import CommentField, DynamicModelChoiceField, TagFilterField
from utilities.forms.rendering import FieldSet
from utilities.forms.widgets import APISelect, DatePicker
@@ -39,7 +40,7 @@ class SoftwareProductVersionForm(NetBoxModelForm):
class SoftwareProductVersionFilterForm(NetBoxModelFilterSetForm):
model = SoftwareProductVersion
fieldsets = ((None, ("q", "tag")),)
fieldsets = (FieldSet(None, ("q", "tag")),)
tag = TagFilterField(model)
+1 -10
View File
@@ -1,5 +1,4 @@
from extras.plugins import PluginMenuButton, PluginMenuItem
from utilities.choices import ButtonColorChoices
from netbox.plugins import PluginMenuButton, PluginMenuItem
menu_items = (
PluginMenuItem(
@@ -10,14 +9,12 @@ menu_items = (
"plugins:netbox_slm:softwareproduct_add",
"Add",
"mdi mdi-plus-thick",
ButtonColorChoices.GREEN,
permissions=["netbox_slm.add_softwareproduct"],
),
PluginMenuButton(
"plugins:netbox_slm:softwareproduct_import",
"Import",
"mdi mdi-upload",
ButtonColorChoices.CYAN,
permissions=["netbox_slm.add_softwareproduct"],
),
),
@@ -30,14 +27,12 @@ menu_items = (
"plugins:netbox_slm:softwareproductversion_add",
"Add",
"mdi mdi-plus-thick",
ButtonColorChoices.GREEN,
permissions=["netbox_slm.add_softwareproductversion"],
),
PluginMenuButton(
"plugins:netbox_slm:softwareproductversion_import",
"Import",
"mdi mdi-upload",
ButtonColorChoices.CYAN,
permissions=["netbox_slm.add_softwareproductversion"],
),
),
@@ -50,14 +45,12 @@ menu_items = (
"plugins:netbox_slm:softwareproductinstallation_add",
"Add",
"mdi mdi-plus-thick",
ButtonColorChoices.GREEN,
permissions=["netbox_slm.add_softwareproductinstallation"],
),
PluginMenuButton(
"plugins:netbox_slm:softwareproductinstallation_import",
"Import",
"mdi mdi-upload",
ButtonColorChoices.CYAN,
permissions=["netbox_slm.add_softwareproductinstallation"],
),
),
@@ -70,14 +63,12 @@ menu_items = (
"plugins:netbox_slm:softwarelicense_add",
"Add",
"mdi mdi-plus-thick",
ButtonColorChoices.GREEN,
permissions=["netbox_slm.add_softwarelicense"],
),
PluginMenuButton(
"plugins:netbox_slm:softwarelicense_import",
"Import",
"mdi mdi-upload",
ButtonColorChoices.CYAN,
permissions=["netbox_slm.add_softwarelicense"],
),
),
@@ -11,58 +11,56 @@
<h5 class="card-header">
Software License
</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">Name</th>
<td>{{ object.name }}</td>
</tr>
<tr>
<th scope="row">Description</th>
<td>{{ object.description }}</td>
</tr>
<tr>
<th scope="row">Type</th>
<td>{{ object.type }}</td>
</tr>
<tr>
<th scope="row">Stored location</th>
<table class="table table-hover attr-table">
<tr>
<th scope="row">Name</th>
<td>{{ object.name }}</td>
</tr>
<tr>
<th scope="row">Description</th>
<td>{{ object.description }}</td>
</tr>
<tr>
<th scope="row">Type</th>
<td>{{ object.type }}</td>
</tr>
<tr>
<th scope="row">Stored location</th>
{% if object.stored_location_url %}
<td><a href="{{ object.stored_location_url }}">{{ object.stored_location_txt }}</a></td>
<td><a href="{{ object.stored_location_url }}">{{ object.stored_location_txt }}</a></td>
{% else %}
<td>{{ object.stored_location_txt }}</td>
<td>{{ object.stored_location_txt }}</td>
{% endif %}
</tr>
<tr>
<th scope="row">Start date</th>
<td>{{ object.start_date }}</td>
</tr>
<tr>
<th scope="row">Expiration date</th>
<td>{{ object.expiration_date }}</td>
</tr>
<tr>
<th scope="row">Software Product</th>
<td>{{ object.software_product }}</td>
</tr>
<tr>
<th scope="row">Version</th>
<td>{{ object.version }}</td>
</tr>
<tr>
<th scope="row">Support</th>
<td>{{ object.support }}</td>
</tr>
<tr>
<th scope="row">License amount</th>
<td>{{ object.license_amount }}</td>
</tr>
<tr>
<th scope="row">Installation</th>
<td>{{ object.installation }}</td>
</tr>
</table>
</div>
</tr>
<tr>
<th scope="row">Start date</th>
<td>{{ object.start_date }}</td>
</tr>
<tr>
<th scope="row">Expiration date</th>
<td>{{ object.expiration_date }}</td>
</tr>
<tr>
<th scope="row">Software Product</th>
<td>{{ object.software_product }}</td>
</tr>
<tr>
<th scope="row">Version</th>
<td>{{ object.version }}</td>
</tr>
<tr>
<th scope="row">Support</th>
<td>{{ object.support }}</td>
</tr>
<tr>
<th scope="row">License amount</th>
<td>{{ object.license_amount }}</td>
</tr>
<tr>
<th scope="row">Installation</th>
<td>{{ object.installation }}</td>
</tr>
</table>
</div>
{% include 'inc/panels/custom_fields.html' %}
{% include 'inc/panels/tags.html' %}
@@ -11,34 +11,32 @@
<h5 class="card-header">
Software Product
</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">Name</th>
<td>{{ object.name }}</td>
</tr>
<tr>
<th scope="row">Description</th>
<td>{{ object.description }}</td>
</tr>
<tr>
<th scope="row">Manufacturer</th>
<td>{{ object.manufacturer }}</td>
</tr>
<tr>
<th scope="row">Versions</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>
{% empty %}
n/a
{% endfor %}
</td>
</tr>
</table>
</div>
<table class="table table-hover attr-table">
<tr>
<th scope="row">Name</th>
<td>{{ object.name }}</td>
</tr>
<tr>
<th scope="row">Description</th>
<td>{{ object.description }}</td>
</tr>
<tr>
<th scope="row">Manufacturer</th>
<td>{{ object.manufacturer }}</td>
</tr>
<tr>
<th scope="row">Versions</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>
{% empty %}
n/a
{% endfor %}
</td>
</tr>
</table>
</div>
{% include 'inc/panels/custom_fields.html' %}
{% include 'inc/panels/tags.html' %}
@@ -11,34 +11,32 @@
<h5 class="card-header">
Software Product Installation
</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<table class="table table-hover attr-table">
{% if object.device %}
<tr>
<th scope="row">Device</th>
<td>{{ object.device }}</td>
</tr>
<tr>
<th scope="row">Device</th>
<td>{{ object.device }}</td>
</tr>
{% elif object.virtualmachine %}
<tr>
<th scope="row">Virtualmachine</th>
<td>{{ object.virtualmachine }}</td>
</tr>
<tr>
<th scope="row">Virtualmachine</th>
<td>{{ object.virtualmachine }}</td>
</tr>
{% else %}
<tr>
<th scope="row">Cluster</th>
<td>{{ object.cluster }}</td>
</tr>
<tr>
<th scope="row">Cluster</th>
<td>{{ object.cluster }}</td>
</tr>
{% endif %}
<tr>
<th scope="row">Software Product</th>
<td>{{ object.software_product }}</td>
</tr>
<tr>
<th scope="row">Version</th>
<td>{{ object.version }}</td>
</tr>
</table>
</div>
<tr>
<th scope="row">Software Product</th>
<td>{{ object.software_product }}</td>
</tr>
<tr>
<th scope="row">Version</th>
<td>{{ object.version }}</td>
</tr>
</table>
</div>
{% include 'inc/panels/custom_fields.html' %}
{% include 'inc/panels/tags.html' %}
@@ -11,50 +11,48 @@
<h5 class="card-header">
Software Product Version
</h5>
<div class="card-body">
<table class="table table-hover attr-table">
<tr>
<th scope="row">Name</th>
<td>{{ object.name }}</td>
</tr>
<tr>
<th scope="row">Release date</th>
<td>{{ object.release_date }}</td>
</tr>
<tr>
<th scope="row">Documentation url</th>
<table class="table table-hover attr-table">
<tr>
<th scope="row">Name</th>
<td>{{ object.name }}</td>
</tr>
<tr>
<th scope="row">Release date</th>
<td>{{ object.release_date }}</td>
</tr>
<tr>
<th scope="row">Documentation url</th>
{% if object.documentation_url %}
<td><a href="{{ object.documentation_url }}">{{ object.documentation_url }}</a></td>
<td><a href="{{ object.documentation_url }}">{{ object.documentation_url }}</a></td>
{% else %}
<td>{{ object.documentation_url }}</td>
<td>{{ object.documentation_url }}</td>
{% endif %}
</tr>
<tr>
<th scope="row">End of support</th>
<td>{{ object.end_of_support }}</td>
</tr>
<tr>
<th scope="row">Filename</th>
</tr>
<tr>
<th scope="row">End of support</th>
<td>{{ object.end_of_support }}</td>
</tr>
<tr>
<th scope="row">Filename</th>
{% if object.file_link %}
<td><a href="{{ object.file_link }}">{{ object.filename }}</a></td>
<td><a href="{{ object.file_link }}">{{ object.filename }}</a></td>
{% else %}
<td>{{ object.filename }}</td>
<td>{{ object.filename }}</td>
{% endif %}
</tr>
<tr>
<th scope="row">File checksum</th>
<td>{{ object.file_checksum }}</td>
</tr>
<tr>
<th scope="row">Release type</th>
<td>{{ object.get_release_type_display }}</td>
</tr>
<tr>
<th scope="row">Installations</th>
<td>{{ object.get_installation_count }}</td>
</tr>
</table>
</div>
</tr>
<tr>
<th scope="row">File checksum</th>
<td>{{ object.file_checksum }}</td>
</tr>
<tr>
<th scope="row">Release type</th>
<td>{{ object.get_release_type_display }}</td>
</tr>
<tr>
<th scope="row">Installations</th>
<td>{{ object.get_installation_count }}</td>
</tr>
</table>
</div>
{% include 'inc/panels/custom_fields.html' %}
{% include 'inc/panels/tags.html' %}