From 020ba1c7c486b80da14dd9c9cb3fa9222c019566 Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Mon, 5 Sep 2016 12:42:46 +0000 Subject: [PATCH] Fixed domain record form validation with SRV records --- orchestra/contrib/domains/forms.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/orchestra/contrib/domains/forms.py b/orchestra/contrib/domains/forms.py index feb90e6a..4bdebcdb 100644 --- a/orchestra/contrib/domains/forms.py +++ b/orchestra/contrib/domains/forms.py @@ -7,7 +7,7 @@ from orchestra.admin.forms import AdminFormSet, AdminFormMixin from . import validators from .helpers import domain_for_validation -from .models import Domain +from .models import Domain, Record class BatchDomainCreationAdminForm(forms.ModelForm): @@ -97,6 +97,11 @@ class ValidateZoneMixin(object): super(ValidateZoneMixin, self).clean() if any(self.errors): return + has_srv = False + for form in self.forms: + has_srv = form.cleaned_data.get('type') == Record.SRV + if has_srv: + break domain_names = [] if self.instance.name: domain_names.append(self.instance.name) @@ -108,7 +113,7 @@ class ValidateZoneMixin(object): data = form.cleaned_data if data and not data['DELETE']: records.append(data) - if '_' in name: + if '_' in name and not has_srv: errors.append(ValidationError( _("%s: Domains containing underscore character '_' must provide an SRV record.") % name ))