Follow the attribution requirements of the Apache License 2.0 for this fork of ICTU/netbox_slm: - add a NOTICE file with the original copyright (ICTU) and the fork's notice - mark every file changed since upstream 1.9.0 as modified (section 4b); the original copyright header in __init__.py is kept - add a visible fork notice and a section on origin, credits, changes and license to the README - point project URLs to this fork (with an Upstream link), list ICTU as author and MrBlake as maintainer, and stop showing ICTU's email address as the plugin contact - ship NOTICE in the package and drop the MANIFEST entry for the removed SECURITY.md Bump version to 1.14.1. Co-Authored-By: Claude Opus 5.5 <[email protected]>
132 lines
4.2 KiB
Python
132 lines
4.2 KiB
Python
# Modified by MrBlake for the NetBox-SLM fork: https://git.mrblake.cc/MrBlake/NetBox-SLM
|
|
# Based on ICTU/netbox_slm (Apache License 2.0). See the LICENSE and NOTICE files.
|
|
from django.forms import DateField, CharField, MultipleChoiceField
|
|
from django.urls import reverse_lazy
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
from dcim.models import Manufacturer
|
|
from netbox.forms import NetBoxModelForm, NetBoxModelFilterSetForm, NetBoxModelImportForm, NetBoxModelBulkEditForm
|
|
from netbox_slm.models import SoftwareProduct, SoftwareProductVersion, SoftwareReleaseTypes
|
|
from utilities.forms.fields import (
|
|
CommentField,
|
|
DynamicModelChoiceField,
|
|
TagFilterField,
|
|
DynamicModelMultipleChoiceField,
|
|
)
|
|
from utilities.forms.rendering import FieldSet
|
|
from utilities.forms.widgets import APISelect, DatePicker
|
|
|
|
|
|
class SoftwareProductVersionForm(NetBoxModelForm):
|
|
comments = CommentField()
|
|
|
|
release_date = DateField(required=False, widget=DatePicker())
|
|
end_of_support = DateField(required=False, widget=DatePicker())
|
|
|
|
software_product = DynamicModelChoiceField(
|
|
queryset=SoftwareProduct.objects.all(),
|
|
required=True,
|
|
label=_("Software Product"),
|
|
widget=APISelect(attrs={"data-url": reverse_lazy("plugins-api:netbox_slm-api:softwareproduct-list")}),
|
|
)
|
|
|
|
class Meta:
|
|
model = SoftwareProductVersion
|
|
fields = (
|
|
"name",
|
|
"description",
|
|
"software_product",
|
|
"release_date",
|
|
"documentation_url",
|
|
"end_of_support",
|
|
"filename",
|
|
"file_checksum",
|
|
"file_link",
|
|
"release_type",
|
|
"tags",
|
|
"comments",
|
|
)
|
|
|
|
|
|
class SoftwareProductVersionFilterForm(NetBoxModelFilterSetForm):
|
|
model = SoftwareProductVersion
|
|
fieldsets = (
|
|
FieldSet("q", "filter_id", "tag"),
|
|
FieldSet("name", "description", "filename", "release_type", "manufacturer_id", "software_product_id"),
|
|
)
|
|
selector_fields = ("q", "filter_id", "name")
|
|
|
|
tag = TagFilterField(model)
|
|
|
|
name = CharField(required=False)
|
|
description = CharField(required=False)
|
|
filename = CharField(required=False)
|
|
|
|
release_type = MultipleChoiceField(required=False, choices=SoftwareReleaseTypes.choices)
|
|
|
|
manufacturer_id = DynamicModelMultipleChoiceField(
|
|
queryset=Manufacturer.objects.all(),
|
|
required=False,
|
|
label=_("Manufacturer"),
|
|
)
|
|
software_product_id = DynamicModelMultipleChoiceField(
|
|
queryset=SoftwareProduct.objects.all(),
|
|
required=False,
|
|
label=_("Software Product"),
|
|
)
|
|
|
|
|
|
class SoftwareProductVersionBulkImportForm(NetBoxModelImportForm):
|
|
release_type = CharField(
|
|
help_text=_("Release type (possible values: %(values)s)") % {"values": SoftwareReleaseTypes.values}
|
|
)
|
|
|
|
class Meta:
|
|
model = SoftwareProductVersion
|
|
fields = (
|
|
"name",
|
|
"description",
|
|
"software_product",
|
|
"release_date",
|
|
"end_of_support",
|
|
"filename",
|
|
"file_checksum",
|
|
"release_type",
|
|
"tags",
|
|
)
|
|
|
|
|
|
class SoftwareProductVersionBulkEditForm(NetBoxModelBulkEditForm):
|
|
model = SoftwareProductVersion
|
|
fieldsets = (
|
|
FieldSet(
|
|
"release_date",
|
|
"documentation_url",
|
|
"end_of_support",
|
|
"filename",
|
|
"file_checksum",
|
|
"file_link",
|
|
"release_type",
|
|
"software_product",
|
|
),
|
|
)
|
|
nullable_fields = ("release_date", "documentation_url", "end_of_support", "filename", "file_checksum", "file_link")
|
|
|
|
tag = TagFilterField(model)
|
|
comments = CommentField()
|
|
|
|
release_date = DateField(required=False, widget=DatePicker())
|
|
documentation_url = CharField(required=False)
|
|
end_of_support = DateField(required=False, widget=DatePicker())
|
|
filename = CharField(required=False)
|
|
file_checksum = CharField(required=False)
|
|
file_link = CharField(required=False)
|
|
|
|
release_type = MultipleChoiceField(required=False, choices=SoftwareReleaseTypes.choices)
|
|
|
|
software_product = DynamicModelChoiceField(
|
|
queryset=SoftwareProduct.objects.all(),
|
|
required=False,
|
|
label=_("Software Product"),
|
|
)
|