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
+2
View File
@@ -10,6 +10,8 @@
* Support NetBox v4.6.5
* Replace the Docker-based setup with Git/Pip installation documentation
* Render tenant group and tenant in a dedicated license form section
* Bump the package version so Git/Pip upgrades replace older installations
## [1.9.0](https://github.com/ICTU/netbox_slm/releases/tag/1.9.0) - 2026-06-25
+10 -1
View File
@@ -38,7 +38,8 @@ grep -qxF "git+https://git.mrblake.cc/MrBlake/NetBox-SLM.git" /opt/netbox/local_
Die Installation muss im Python-Virtual-Environment von NetBox erfolgen:
```bash
/opt/netbox/venv/bin/pip install "git+https://git.mrblake.cc/MrBlake/NetBox-SLM.git"
/opt/netbox/venv/bin/pip install --upgrade --force-reinstall \
"git+https://git.mrblake.cc/MrBlake/NetBox-SLM.git"
```
Alternativ können alle lokalen Anforderungen installiert werden:
@@ -47,6 +48,14 @@ Alternativ können alle lokalen Anforderungen installiert werden:
/opt/netbox/venv/bin/pip install -r /opt/netbox/local_requirements.txt
```
Die installierte Version kann anschließend geprüft werden:
```bash
/opt/netbox/venv/bin/pip show netbox-slm
```
Für diese Variante muss dort mindestens Version `1.9.1` stehen.
### 3. Plugin in NetBox aktivieren
In `/opt/netbox/netbox/netbox/configuration.py` ergänzen:
+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)