10719 fix regression

This commit is contained in:
Arthur 2022-10-25 15:23:09 -07:00
parent 830a82fa7e
commit 766e9ff31b

View File

@ -932,18 +932,19 @@ class FHRPGroupEditView(generic.ObjectEditView):
return return_url
def save_related_data(self, request, form, obj):
ipaddress = IPAddress(
vrf=form.cleaned_data['ip_vrf'],
address=form.cleaned_data['ip_address'],
status=form.cleaned_data['ip_status'],
role=FHRP_PROTOCOL_ROLE_MAPPINGS.get(form.cleaned_data['protocol'], IPAddressRoleChoices.ROLE_VIP),
assigned_object=obj
)
ipaddress.save()
if form.cleaned_data.get('ip_address'):
ipaddress = IPAddress(
vrf=form.cleaned_data['ip_vrf'],
address=form.cleaned_data['ip_address'],
status=form.cleaned_data['ip_status'],
role=FHRP_PROTOCOL_ROLE_MAPPINGS.get(form.cleaned_data['protocol'], IPAddressRoleChoices.ROLE_VIP),
assigned_object=obj
)
ipaddress.save()
# Check that the new IPAddress conforms with any assigned object-level permissions
if not IPAddress.objects.restrict(request.user, 'add').filter(pk=ipaddress.pk).first():
raise PermissionsViolation()
# Check that the new IPAddress conforms with any assigned object-level permissions
if not IPAddress.objects.restrict(request.user, 'add').filter(pk=ipaddress.pk).first():
raise PermissionsViolation()
class FHRPGroupDeleteView(generic.ObjectDeleteView):