Merge "Add option for records pointing to domain"

This commit is contained in:
Jenkins 2016-07-11 12:18:46 +00:00 committed by Gerrit Code Review
commit 5627ddb4a6
2 changed files with 8 additions and 5 deletions

View File

@ -395,9 +395,9 @@ class RecordForm(forms.SelfHandlingForm):
# Name field # Name field
if self._is_field_blank(cleaned_data, 'name'): if self._is_field_blank(cleaned_data, 'name'):
if record_type in ['A', 'AAAA', 'CNAME', 'SRV', 'TXT', 'PTR']: if record_type in ['CNAME', 'SRV', 'PTR']:
self._add_required_field_error('name') self._add_required_field_error('name')
elif record_type == 'MX': elif record_type in ['MX', 'A', 'AAAA', 'TXT']:
cleaned_data['name'] = domain_name cleaned_data['name'] = domain_name
else: else:
if record_type == 'SRV': if record_type == 'SRV':

View File

@ -100,7 +100,8 @@ class ARecordFormTests(base.BaseRecordFormCleanTests):
def test_missing_name_field(self): def test_missing_name_field(self):
self.form.cleaned_data['name'] = '' self.form.cleaned_data['name'] = ''
self.form.clean() self.form.clean()
self.assert_required_error('name') self.assert_no_errors()
self.assertIsNotNone(self.form.cleaned_data['name'])
def test_missing_data_field(self): def test_missing_data_field(self):
self.form.cleaned_data['data'] = '' self.form.cleaned_data['data'] = ''
@ -162,7 +163,8 @@ class AAAARecordFormTests(base.BaseRecordFormCleanTests):
def test_missing_name_field(self): def test_missing_name_field(self):
self.form.cleaned_data['name'] = '' self.form.cleaned_data['name'] = ''
self.form.clean() self.form.clean()
self.assert_required_error('name') self.assert_no_errors()
self.assertIsNotNone(self.form.cleaned_data['name'])
def test_missing_data_field(self): def test_missing_data_field(self):
self.form.cleaned_data['data'] = '' self.form.cleaned_data['data'] = ''
@ -317,7 +319,8 @@ class TXTRecordFormTests(base.BaseRecordFormCleanTests):
def test_missing_name_field(self): def test_missing_name_field(self):
self.form.cleaned_data['name'] = '' self.form.cleaned_data['name'] = ''
self.form.clean() self.form.clean()
self.assert_required_error('name') self.assert_no_errors()
self.assertIsNotNone(self.form.cleaned_data['name'])
def test_missing_txt_field(self): def test_missing_txt_field(self):
self.form.cleaned_data['txt'] = '' self.form.cleaned_data['txt'] = ''