From cc181c79c339ffe2acedc4c5d9764462941671f8 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 16 Nov 2015 21:56:49 +0530 Subject: [PATCH] Minor styling fixes for domain name validator --- plinth/modules/config/config.py | 11 ++++++----- plinth/modules/config/tests/test_config.py | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plinth/modules/config/config.py b/plinth/modules/config/config.py index 51ce593be..9989c406c 100644 --- a/plinth/modules/config/config.py +++ b/plinth/modules/config/config.py @@ -60,11 +60,12 @@ class TrimmedCharField(forms.CharField): return super(TrimmedCharField, self).clean(value) -def domain_labelvalidator(domainname): - """Validating Domain Name Labels""" - for label in domainname.split("."): +def domain_label_validator(domainname): + """Validate domain name labels.""" + for label in domainname.split('.'): if not re.match(HOSTNAME_REGEX, label): - raise ValidationError(ugettext_lazy('Invalid Domain Name')) + raise ValidationError(_('Invalid domain name')) + class ConfigurationForm(forms.Form): """Main system configuration form""" @@ -101,7 +102,7 @@ class ConfigurationForm(forms.Form): validators.RegexValidator( r'^[a-zA-Z0-9]([-a-zA-Z0-9.]{,251}[a-zA-Z0-9])?$', ugettext_lazy('Invalid domain name')), - domain_labelvalidator]) + domain_label_validator]) def init(): diff --git a/plinth/modules/config/tests/test_config.py b/plinth/modules/config/tests/test_config.py index d22b83fff..3822e942b 100644 --- a/plinth/modules/config/tests/test_config.py +++ b/plinth/modules/config/tests/test_config.py @@ -47,7 +47,6 @@ class TestConfig(unittest.TestCase): def test_domainname_field(self): """Test that domainname field accepts only valid domainnames.""" - valid_domainnames = [ '', 'a', '0a', 'a0', 'AAA', '00', '0-0', 'example-hostname', 'example', 'example.org', 'a.b.c.d', 'a-0.b-0.c-0',