Add hostname validator

Change-Id: Ic735aec1e667d821e2b1aac552ce7731d867accd
This commit is contained in:
Ekaterina Fedorova 2013-06-18 12:18:09 +04:00
parent f7d275ad3b
commit b42d369130
2 changed files with 6 additions and 1 deletions

View File

@ -101,12 +101,18 @@ class ServiceConfigurationForm(forms.Form):
class CommonPropertiesExtension(object):
hostname_re = re.compile(
r'^(([a-zA-Z0-9#][a-zA-Z0-9-#]*[a-zA-Z0-9#])\.)'
r'*([A-Za-z0-9#]|[A-Za-z0-9#][A-Za-z0-9-#]*[A-Za-z0-9#])$')
validate_hostname = RegexValidator(hostname_re, _('text'))
def __init__(self):
self.fields.insert(
len(self.fields), 'unit_name_template',
forms.CharField(
label=_('Hostname template'),
required=False,
validators=[self.validate_hostname],
help_text='You can set a template for machine hostname. \
Use # for incrementation: host# would be host1, host2, etc. \
Note: We do not have validation for this field.\

View File

@ -159,7 +159,6 @@ class IndexView(tables.DataTableView):
'Service, check connection details.')
except HTTPInternalServerError:
messages.error(self.request, 'Environment doesn\'t exist')
return environments