Aurélien Bompard has proposed merging lp:~abompard/postorius/fix_web_host into 
lp:postorius.

Requested reviews:
  Mailman Coders (mailman-coders)

For more details, see:
https://code.launchpad.net/~abompard/postorius/fix_web_host/+merge/216203

This fixes the validation of the web host.
-- 
https://code.launchpad.net/~abompard/postorius/fix_web_host/+merge/216203
Your team Mailman Coders is requested to review the proposed merge of 
lp:~abompard/postorius/fix_web_host into lp:postorius.
=== modified file 'src/postorius/forms.py'
--- src/postorius/forms.py	2014-04-14 20:33:57 +0000
+++ src/postorius/forms.py	2014-04-16 20:22:09 +0000
@@ -17,7 +17,7 @@
 # Postorius.  If not, see <http://www.gnu.org/licenses/>.
 
 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

=== modified file 'src/postorius/tests/test_forms.py'
--- src/postorius/tests/test_forms.py	2014-03-15 21:36:39 +0000
+++ src/postorius/tests/test_forms.py	2014-04-16 20:22:09 +0000
@@ -16,7 +16,7 @@
 # Postorius.  If not, see <http://www.gnu.org/licenses/>.
 from django.utils import unittest
 
-from postorius.forms import UserPreferences
+from postorius.forms import UserPreferences, DomainNew
 
 class UserPreferencesTest(unittest.TestCase):
 
@@ -28,3 +28,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': '[email protected]',
+        })
+        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': '[email protected]',
+        })
+        self.assertFalse(form.is_valid())

_______________________________________________
Mailman-coders mailing list
[email protected]
https://mail.python.org/mailman/listinfo/mailman-coders

Reply via email to