1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Attributed all model ValidationErrors to specific fields (where appropriate)

This commit is contained in:
Jeremy Stretch
2016-10-21 15:39:13 -04:00
parent 13243785f1
commit fc2ac8a02b
5 changed files with 117 additions and 74 deletions

View File

@ -172,16 +172,6 @@ class PrefixForm(BootstrapMixin, CustomFieldForm):
else:
self.fields['vlan'].choices = []
def clean_prefix(self):
prefix = self.cleaned_data['prefix']
if prefix.version == 4 and prefix.prefixlen == 32:
raise forms.ValidationError("Cannot create host addresses (/32) as prefixes. These should be IPv4 "
"addresses instead.")
elif prefix.version == 6 and prefix.prefixlen == 128:
raise forms.ValidationError("Cannot create host addresses (/128) as prefixes. These should be IPv6 "
"addresses instead.")
return prefix
class PrefixFromCSVForm(forms.ModelForm):
vrf = forms.ModelChoiceField(queryset=VRF.objects.all(), required=False, to_field_name='rd',