Explorar el Código

13500 fix l2vpntermination bulk update

Arthur hace 2 años
padre
commit
fe95cb434a
Se han modificado 1 ficheros con 4 adiciones y 2 borrados
  1. 4 2
      netbox/ipam/forms/bulk_import.py

+ 4 - 2
netbox/ipam/forms/bulk_import.py

@@ -548,9 +548,11 @@ class L2VPNTerminationImportForm(NetBoxModelImportForm):
 
 
         if self.cleaned_data.get('device') and self.cleaned_data.get('virtual_machine'):
         if self.cleaned_data.get('device') and self.cleaned_data.get('virtual_machine'):
             raise ValidationError('Cannot import device and VM interface terminations simultaneously.')
             raise ValidationError('Cannot import device and VM interface terminations simultaneously.')
-        if not (self.cleaned_data.get('interface') or self.cleaned_data.get('vlan')):
+        if not self.instance and not (self.cleaned_data.get('interface') or self.cleaned_data.get('vlan')):
             raise ValidationError('Each termination must specify either an interface or a VLAN.')
             raise ValidationError('Each termination must specify either an interface or a VLAN.')
         if self.cleaned_data.get('interface') and self.cleaned_data.get('vlan'):
         if self.cleaned_data.get('interface') and self.cleaned_data.get('vlan'):
             raise ValidationError('Cannot assign both an interface and a VLAN.')
             raise ValidationError('Cannot assign both an interface and a VLAN.')
 
 
-        self.instance.assigned_object = self.cleaned_data.get('interface') or self.cleaned_data.get('vlan')
+        # if this is an update we might not have interface or vlan in the form data
+        if self.cleaned_data.get('interface') or self.cleaned_data.get('vlan'):
+            self.instance.assigned_object = self.cleaned_data.get('interface') or self.cleaned_data.get('vlan')