feat: drag and drop disks between slots; fix RAID group form on NetBox 4.7

Disks on the slot grid can be dragged onto a free slot to move them or onto
an occupied slot to swap both disks. Moves are saved immediately with
changelog entries and require netbox_utilities.change_disk.

NetBoxModelForm.clean() returns None on NetBox 4.7, which broke creating
RAID groups with an AttributeError. The disk forms now read
self.cleaned_data instead of the return value.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
MrBlakeandClaude Opus 5.5 committed 2026-10-19 12:31:56 +02:00
1 parent a296c57536
commit 595d6a2b71
6 files changed
+159 -8

No files matched your search

+8 -4
View File
@@ -144,7 +144,8 @@ class DiskBayLayoutForm(forms.ModelForm):
}
def clean(self):
cleaned_data = super().clean()
super().clean()
cleaned_data = self.cleaned_data
slot_count, rows = cleaned_data.get("slot_count"), cleaned_data.get("rows")
if slot_count and rows and rows > slot_count:
self.add_error("rows", "Es kann nicht mehr Reihen als Steckplätze geben.")
@@ -190,7 +191,8 @@ class DiskBulkFillForm(forms.Form):
widget.attrs["class"] = f"{css} {widget.attrs.get('class', '')}".strip()
def clean(self):
cleaned_data = super().clean()
super().clean()
cleaned_data = self.cleaned_data
slots = cleaned_data.get("slots") or []
serials = disks.parse_serials(cleaned_data.get("serials"))
if len(serials) > len(slots):
@@ -275,7 +277,8 @@ class RAIDGroupForm(NetBoxModelForm):
self.initial["members"] = list(self.instance.disks.values_list("pk", flat=True))
def clean(self):
cleaned_data = super().clean()
super().clean()
cleaned_data = self.cleaned_data
device = cleaned_data.get("device")
foreign = [disk for disk in cleaned_data.get("members") or () if device and disk.device_id != device.pk]
if foreign:
@@ -391,7 +394,8 @@ class DiskImportForm(NetBoxModelImportForm):
return self.cleaned_data.get("raid_group") or ""
def clean(self):
cleaned_data = super().clean()
super().clean()
cleaned_data = self.cleaned_data
if cleaned_data.get("status") in (None, ""):
cleaned_data["status"] = disks.STATUS_ACTIVE
self.instance.status = disks.STATUS_ACTIVE