Răsfoiți Sursa

Closes #3524: Enable bulk editing of power outlet/power port associations

Jeremy Stretch 6 ani în urmă
părinte
comite
fe85dc1186
2 a modificat fișierele cu 15 adăugiri și 1 ștergeri
  1. 4 0
      CHANGELOG.md
  2. 11 1
      netbox/dcim/forms.py

+ 4 - 0
CHANGELOG.md

@@ -1,5 +1,9 @@
 v2.6.5 (FUTURE)
 
+## Enhancements
+
+* [#3524](https://github.com/netbox-community/netbox/issues/3524) -  Enable bulk editing of power outlet/power port associations
+
 ## Bug Fixes
 
 * [#3464](https://github.com/netbox-community/netbox/issues/3464) -  Fix foreground text color on color picker fields

+ 11 - 1
netbox/dcim/forms.py

@@ -2106,6 +2106,10 @@ class PowerOutletBulkEditForm(BootstrapMixin, AddRemoveTagsForm, BulkEditForm):
         choices=add_blank_choice(POWERFEED_LEG_CHOICES),
         required=False,
     )
+    power_port = forms.ModelChoiceField(
+        queryset=PowerPort.objects.all(),
+        required=False
+    )
     description = forms.CharField(
         max_length=100,
         required=False
@@ -2113,9 +2117,15 @@ class PowerOutletBulkEditForm(BootstrapMixin, AddRemoveTagsForm, BulkEditForm):
 
     class Meta:
         nullable_fields = [
-            'feed_leg', 'description',
+            'feed_leg', 'power_port', 'description',
         ]
 
+    def __init__(self, *args, **kwargs):
+        super().__init__(*args, **kwargs)
+
+        # Limit power_port queryset to PowerPorts which belong to the parent Device
+        self.fields['power_port'].queryset = PowerPort.objects.filter(device=self.parent_obj)
+
 
 class PowerOutletBulkRenameForm(BulkRenameForm):
     pk = forms.ModelMultipleChoiceField(