fix: render tenancy fields in license form

Define an explicit tenancy fieldset and bump the package version to 1.9.1 so Git/Pip upgrades replace older installations.
This commit is contained in:
2026-07-24 15:34:01 +02:00
parent e1c817229b
commit 7ca670c717
5 changed files with 45 additions and 2 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ limitations under the License.
from netbox.plugins import PluginConfig
__version__ = "1.9.0"
__version__ = "1.9.1"
class SLMConfig(PluginConfig):
+23
View File
@@ -24,6 +24,29 @@ from utilities.forms.widgets import APISelect, DatePicker
class SoftwareLicenseForm(NetBoxModelForm):
comments = CommentField()
fieldsets = (
FieldSet(
"name",
"description",
"software_product",
"version",
"installation",
name="Software License",
),
FieldSet("tenant_group", "tenant", name="Tenancy"),
FieldSet(
"type",
"spdx_expression",
"stored_location",
"stored_location_url",
"start_date",
"expiration_date",
"support",
"license_amount",
name="License Details",
),
FieldSet("tags", name="Tags"),
)
spdx_expression = ChoiceField(required=False, choices=spdx_license_names(), label="SPDX expression")
stored_location_url = LaxURLField(required=False)
+9
View File
@@ -1,4 +1,5 @@
from django.core.exceptions import ValidationError
from netbox_slm.forms import SoftwareLicenseForm
from tenancy.models import Tenant, TenantGroup
from .base import SlmBaseTestCase
@@ -64,6 +65,14 @@ class ModelTestCase(SlmBaseTestCase):
self.assertEqual(self.tenant_group, self.software_license.tenant_group)
self.assertEqual(self.tenant, self.software_license.tenant)
def test_software_license_form_renders_tenancy_fields(self):
form = SoftwareLicenseForm(instance=self.software_license)
self.assertIn("tenant_group", form.fields)
self.assertIn("tenant", form.fields)
self.assertTrue(
any("tenant_group" in fieldset.items and "tenant" in fieldset.items for fieldset in form.fieldsets)
)
def test_software_license_rejects_tenant_from_other_group(self):
other_group = TenantGroup.objects.create(name="other group", slug="other-group")
other_tenant = Tenant.objects.create(name="other tenant", slug="other-tenant", group=other_group)