Commit 668d3099 by Dudás Ádám

fw: simplyfy method for mccabe

parent 34b69cf4
...@@ -691,18 +691,22 @@ class Record(models.Model): ...@@ -691,18 +691,22 @@ class Record(models.Model):
"""Validate a record.""" """Validate a record."""
if not self.address: if not self.address:
raise ValidationError(_("Address must be specified!")) raise ValidationError(_("Address must be specified!"))
if self.type == 'A':
val_ipv4(self.address) try:
elif self.type == 'AAAA': validator = {
val_ipv6(self.address) 'A': val_ipv4,
elif self.type in ['CNAME', 'NS', 'PTR']: 'AAAA': val_ipv6,
val_domain(self.address) 'CNAME': val_domain,
elif self.type == 'MX': 'MX': val_mx,
val_mx(self.address) 'NS': val_domain,
elif self.type == 'TXT': 'PTR': val_domain,
pass 'TXT': None,
else: }[self.type]
except KeyError:
raise ValidationError(_("Unknown record type.")) raise ValidationError(_("Unknown record type."))
else:
if validator:
validator(self.address)
def clean(self): def clean(self):
"""Validate the Record to be saved. """Validate the Record to be saved.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment