diff --git a/src/postorius/forms.py b/src/postorius/forms.py index c0ff959..20c897d 100644 --- a/src/postorius/forms.py +++ b/src/postorius/forms.py @@ -17,7 +17,7 @@ # Postorius. If not, see . from django import forms -from django.core.validators import validate_email +from django.core.validators import validate_email, URLValidator from django.utils.translation import gettext as _ from fieldset_forms import FieldsetForm from django.forms.models import modelformset_factory @@ -56,7 +56,7 @@ def clean_web_host(self): web_host = self.cleaned_data['web_host'] try: - validate_email('mail@' + web_host) + URLValidator()(web_host) except: raise forms.ValidationError(_("Please enter a valid Web Host")) return web_host diff --git a/src/postorius/templates/postorius/domain_new.html b/src/postorius/templates/postorius/domain_new.html index d28bac0..205e1ac 100644 --- a/src/postorius/templates/postorius/domain_new.html +++ b/src/postorius/templates/postorius/domain_new.html @@ -24,7 +24,7 @@
{{ form.web_host}} -

Example: www.domain.org

+

Example: http://www.domain.org

diff --git a/src/postorius/tests/test_forms.py b/src/postorius/tests/test_forms.py index 5748f68..0335bea 100644 --- a/src/postorius/tests/test_forms.py +++ b/src/postorius/tests/test_forms.py @@ -16,7 +16,7 @@ # Postorius. If not, see . from django.utils import unittest -from postorius.forms import UserPreferences +from postorius.forms import UserPreferences, DomainNew class UserPreferencesTest(unittest.TestCase): @@ -29,3 +29,23 @@ 'receive_own_postings': 'False', }) self.assertTrue(form.is_valid()) + +class DomainNewTest(unittest.TestCase): + + def test_form_fields_webhost(self): + form = DomainNew({ + 'mail_host': 'mailman.most-desirable.org', + 'web_host': 'http://mailman.most-desirable.org', + 'description': 'The Most Desirable organization', + 'contact_address': 'contact@mailman.most-desirable.org', + }) + self.assertTrue(form.is_valid()) + + def test_form_fields_webhost_invalid(self): + form = DomainNew({ + 'mail_host': 'mailman.most-desirable.org', + 'web_host': 'mailman.most-desirable.org', + 'description': 'The Most Desirable organization', + 'contact_address': 'contact@mailman.most-desirable.org', + }) + self.assertFalse(form.is_valid())