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]>
79 lines
2.1 KiB
Python
79 lines
2.1 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 CharField
|
|
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
|
|
from utilities.forms.fields import (
|
|
CommentField,
|
|
DynamicModelChoiceField,
|
|
TagFilterField,
|
|
DynamicModelMultipleChoiceField,
|
|
)
|
|
from utilities.forms.rendering import FieldSet
|
|
|
|
|
|
class SoftwareProductForm(NetBoxModelForm):
|
|
comments = CommentField()
|
|
|
|
manufacturer = DynamicModelChoiceField(
|
|
queryset=Manufacturer.objects.all(),
|
|
required=True,
|
|
)
|
|
|
|
class Meta:
|
|
model = SoftwareProduct
|
|
fields = (
|
|
"name",
|
|
"description",
|
|
"manufacturer",
|
|
"tags",
|
|
"comments",
|
|
)
|
|
|
|
|
|
class SoftwareProductFilterForm(NetBoxModelFilterSetForm):
|
|
model = SoftwareProduct
|
|
fieldsets = (
|
|
FieldSet("q", "filter_id", "tag"),
|
|
FieldSet("name", "description", "manufacturer_id"),
|
|
)
|
|
selector_fields = ("q", "filter_id", "name")
|
|
|
|
tag = TagFilterField(model)
|
|
|
|
name = CharField(required=False)
|
|
description = CharField(required=False)
|
|
manufacturer_id = DynamicModelMultipleChoiceField(
|
|
queryset=Manufacturer.objects.all(),
|
|
required=False,
|
|
label=_("Manufacturer"),
|
|
)
|
|
|
|
|
|
class SoftwareProductBulkImportForm(NetBoxModelImportForm):
|
|
class Meta:
|
|
model = SoftwareProduct
|
|
fields = (
|
|
"name",
|
|
"description",
|
|
"manufacturer",
|
|
"tags",
|
|
)
|
|
|
|
|
|
class SoftwareProductBulkEditForm(NetBoxModelBulkEditForm):
|
|
model = SoftwareProduct
|
|
fieldsets = (FieldSet("manufacturer"),)
|
|
nullable_fields = ("manufacturer", "comments")
|
|
|
|
tag = TagFilterField(model)
|
|
comments = CommentField()
|
|
|
|
manufacturer = DynamicModelChoiceField(
|
|
queryset=Manufacturer.objects.all(),
|
|
required=False,
|
|
)
|