mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
15029 check if duplicate FHRP group assignment
This commit is contained in:
@ -507,6 +507,24 @@ class FHRPGroupAssignmentForm(BootstrapMixin, forms.ModelForm):
|
|||||||
for ipaddress in ipaddresses:
|
for ipaddress in ipaddresses:
|
||||||
self.fields['group'].widget.add_query_param('related_ip', ipaddress.pk)
|
self.fields['group'].widget.add_query_param('related_ip', ipaddress.pk)
|
||||||
|
|
||||||
|
def clean_group(self):
|
||||||
|
group = self.cleaned_data['group']
|
||||||
|
|
||||||
|
conflicting_assignments = FHRPGroupAssignment.objects.filter(
|
||||||
|
interface_type=self.instance.interface_type,
|
||||||
|
interface_id=self.instance.interface_id,
|
||||||
|
group=group
|
||||||
|
)
|
||||||
|
if self.instance.id:
|
||||||
|
conflicting_assignments = conflicting_assignments.exclude(id=self.instance.id)
|
||||||
|
|
||||||
|
if conflicting_assignments.exists():
|
||||||
|
raise forms.ValidationError(
|
||||||
|
_('Assignment already exists')
|
||||||
|
)
|
||||||
|
|
||||||
|
return group
|
||||||
|
|
||||||
|
|
||||||
class VLANGroupForm(NetBoxModelForm):
|
class VLANGroupForm(NetBoxModelForm):
|
||||||
scope_type = ContentTypeChoiceField(
|
scope_type = ContentTypeChoiceField(
|
||||||
|
Reference in New Issue
Block a user