Parcourir la source

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

Jeremy Stretch il y a 6 ans
Parent
commit
fe85dc1186
2 fichiers modifiés avec 15 ajouts et 1 suppressions
  1. 4 0
      CHANGELOG.md
  2. 11 1
      netbox/dcim/forms.py

+ 4 - 0
CHANGELOG.md

@@ -1,5 +1,9 @@
 v2.6.5 (FUTURE)
 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
 ## Bug Fixes
 
 
 * [#3464](https://github.com/netbox-community/netbox/issues/3464) -  Fix foreground text color on color picker fields
 * [#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),
         choices=add_blank_choice(POWERFEED_LEG_CHOICES),
         required=False,
         required=False,
     )
     )
+    power_port = forms.ModelChoiceField(
+        queryset=PowerPort.objects.all(),
+        required=False
+    )
     description = forms.CharField(
     description = forms.CharField(
         max_length=100,
         max_length=100,
         required=False
         required=False
@@ -2113,9 +2117,15 @@ class PowerOutletBulkEditForm(BootstrapMixin, AddRemoveTagsForm, BulkEditForm):
 
 
     class Meta:
     class Meta:
         nullable_fields = [
         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):
 class PowerOutletBulkRenameForm(BulkRenameForm):
     pk = forms.ModelMultipleChoiceField(
     pk = forms.ModelMultipleChoiceField(