Commit 6c54484e authored by Nikhil Rayaprolu's avatar Nikhil Rayaprolu Committed by Simon Hanna

Show error message below the mailhost when dupicate mailhost is entered

parent 8a3ed6ac
......@@ -68,7 +68,6 @@ class DomainCreationTest(ViewTestCase):
'site': '1',
}
response = self.client.post(reverse('domain_new'), post_data)
self.assertContains(response, 'Please check the errors below')
self.assertContains(response, 'Please enter a valid domain name')
# self.assertHasErrorMessage(response)
self.assertEquals(response.status_code, 200)
......@@ -69,15 +69,13 @@ def domain_new(request):
except MailmanApiError:
return utils.render_api_error(request)
except HTTPError as e:
messages.error(request, e)
form.add_error('mail_host', e.reason)
else:
messages.success(request, _("New Domain registered"))
MailDomain.objects.get_or_create(
site=form.cleaned_data['site'],
mail_domain=form.cleaned_data['mail_host'])
return redirect("domain_index")
else:
messages.error(request, _('Please check the errors below'))
MailDomain.objects.get_or_create(
site=form.cleaned_data['site'],
mail_domain=form.cleaned_data['mail_host'])
return redirect("domain_index")
else:
form = DomainForm(initial=form_initial)
return render(request, 'postorius/domain/new.html', {'form': form})
......
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 to comment