mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-18 13:06:30 -06:00
Fixes #8102 - Add validation around assigned objects
This commit is contained in:
parent
14fc37a8b8
commit
82932ae7a5
@ -22,6 +22,7 @@
|
|||||||
* [#8088](https://github.com/netbox-community/netbox/issues/8088) - Improve legibility of text in labels with light-colored backgrounds
|
* [#8088](https://github.com/netbox-community/netbox/issues/8088) - Improve legibility of text in labels with light-colored backgrounds
|
||||||
* [#8092](https://github.com/netbox-community/netbox/issues/8092) - Rack elevations should not include device asset tags
|
* [#8092](https://github.com/netbox-community/netbox/issues/8092) - Rack elevations should not include device asset tags
|
||||||
* [#8096](https://github.com/netbox-community/netbox/issues/8096) - Fix DataError during change logging of objects with very long string representations
|
* [#8096](https://github.com/netbox-community/netbox/issues/8096) - Fix DataError during change logging of objects with very long string representations
|
||||||
|
* [#8102](https://github.com/netbox-community/netbox/issues/8102) - Cause validation error when editing IPAddress when more than one object is selected for assignment
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -461,6 +461,20 @@ class IPAddressForm(TenancyForm, CustomFieldModelForm):
|
|||||||
def clean(self):
|
def clean(self):
|
||||||
super().clean()
|
super().clean()
|
||||||
|
|
||||||
|
if self.cleaned_data['interface'] and self.cleaned_data['vminterface'] and self.cleaned_data['fhrpgroup']:
|
||||||
|
self.add_error('interface', "Can only assign an interface, VM interface or FHRP group")
|
||||||
|
self.add_error('vminterface', "Can only assign an interface, VM interface or FHRP group")
|
||||||
|
self.add_error('fhrpgroup', "Can only assign an interface, VM interface or FHRP group")
|
||||||
|
elif self.cleaned_data['interface'] and self.cleaned_data['vminterface']:
|
||||||
|
self.add_error('interface', "Can only assign an interface or VM interface")
|
||||||
|
self.add_error('vminterface', "Can only assign an interface or VM interface")
|
||||||
|
elif self.cleaned_data['interface'] and self.cleaned_data['fhrpgroup']:
|
||||||
|
self.add_error('interface', "Can only assign an interface or FHRP group")
|
||||||
|
self.add_error('fhrpgroup', "Can only assign an interface or FHRP group")
|
||||||
|
elif self.cleaned_data['vminterface'] and self.cleaned_data['fhrpgroup']:
|
||||||
|
self.add_error('vminterface', "Can only assign an VM interface or FHRP group")
|
||||||
|
self.add_error('fhrpgroup', "Can only assign an VM interface or FHRP group")
|
||||||
|
|
||||||
# Handle object assignment
|
# Handle object assignment
|
||||||
if self.cleaned_data['interface']:
|
if self.cleaned_data['interface']:
|
||||||
self.instance.assigned_object = self.cleaned_data['interface']
|
self.instance.assigned_object = self.cleaned_data['interface']
|
||||||
|
Loading…
Reference in New Issue
Block a user