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:
@@ -16,7 +16,7 @@ limitations under the License.
|
||||
|
||||
from netbox.plugins import PluginConfig
|
||||
|
||||
__version__ = "1.9.0"
|
||||
__version__ = "1.9.1"
|
||||
|
||||
|
||||
class SLMConfig(PluginConfig):
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user