From 85dd1a5b28e95028336149456e04be2c168eab5a Mon Sep 17 00:00:00 2001 From: Ekaterina Fedorova Date: Tue, 4 Jun 2013 18:11:28 +0400 Subject: [PATCH] In forms mark all non-required fileds as Optional. Light fixes in service creation Change-Id: Idbe9a825700f03e811ef39918b74e65a23ebe6b9 --- muranodashboard/panel/forms.py | 112 +++++++++--------- muranodashboard/templates/_services_tabs.html | 12 +- 2 files changed, 61 insertions(+), 63 deletions(-) diff --git a/muranodashboard/panel/forms.py b/muranodashboard/panel/forms.py index ddce47461..de2c99118 100644 --- a/muranodashboard/panel/forms.py +++ b/muranodashboard/panel/forms.py @@ -27,22 +27,18 @@ class PasswordField(forms.CharField): special_characters = '!@#$%^&*()_+|\/.,~?><:{}' password_re = re.compile('^.*(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[%s]).*$' % special_characters) - validate_password = RegexValidator(password_re, _('Your password must \ - include at least one letter, \ - at least one number and at least \ - one special character'), 'invalid') + validate_password = RegexValidator( + password_re, _('Your password must include at least one letter, one \ + number and one special character'), 'invalid') def __init__(self, label, *args, **kwargs): - super(PasswordField, self).__init__(min_length=7, max_length=255, - required=True, validators= - [self.validate_password], - label=label, - error_messages={ - 'invalid': - self.validate_password.message}, - widget=forms.PasswordInput( - render_value=False), - *args, **kwargs) + super(PasswordField, self).__init__( + min_length=7, + max_length=255, + validators=[self.validate_password], + label=label, + error_messages={'invalid': self.validate_password.message}, + widget=forms.PasswordInput(render_value=False), *args, **kwargs) class WizardFormServiceType(forms.Form): @@ -73,28 +69,30 @@ class CommonPropertiesExtension(object): len(self.fields), 'unit_name_template', forms.CharField(label=_('Hostname template'), required=False)) + for field, instance in self.fields.iteritems(): + if not instance.required: + instance.widget.attrs['placeholder'] = 'Optional' + class WizardFormADConfiguration(forms.Form, CommonPropertiesExtension): domain_name_re = re.compile( r'^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$') validate_domain_name = RegexValidator(domain_name_re, - _(u'Enter a valid \ - Standard DNS domain name'), + _(u'Enter a valid domain name'), 'invalid') - dc_name = forms.CharField(label=_('Domain Name'), - min_length=2, - max_length=64, - required=True, - validators=[validate_domain_name], - error_messages= - {'invalid': validate_domain_name.message}) + dc_name = forms.CharField( + label=_('Domain Name'), + min_length=2, + max_length=64, + validators=[validate_domain_name], + error_messages={'invalid': validate_domain_name.message}) - dc_count = forms.IntegerField(label=_('Instance Count'), - required=True, - min_value=1, - max_value=100, - initial=1) + dc_count = forms.IntegerField( + label=_('Instance Count'), + min_value=1, + max_value=100, + initial=1) adm_password = PasswordField(_('Administrator password')) @@ -108,20 +106,21 @@ class WizardFormADConfiguration(forms.Form, CommonPropertiesExtension): class WizardFormIISConfiguration(forms.Form, CommonPropertiesExtension): name_re = re.compile(r'^[-\w]+$') validate_name = RegexValidator(name_re, - _(u'Enter a valid name consisting of \ - letters, numbers, underscores or \ - hyphens.'), 'invalid') + _(u'Just letters, numbers, underscores \ + or hyphens are allowed.'), 'invalid') - iis_name = forms.CharField(label=_('Service Name'), - min_length=2, max_length=64, - required=True, validators=[validate_name], - error_messages= - {'invalid': validate_name.message}) + iis_name = forms.CharField( + label=_('Service Name'), + min_length=2, + max_length=64, + validators=[validate_name], + error_messages={'invalid': validate_name.message}) adm_password = PasswordField(_('Administrator password')) - iis_domain = forms.ChoiceField(label=_('Member of the Domain'), - required=False) + iis_domain = forms.ChoiceField( + label=_('Domain'), + required=False) def __init__(self, request, *args, **kwargs): super(WizardFormIISConfiguration, self).__init__(*args, **kwargs) @@ -132,38 +131,37 @@ class WizardFormIISConfiguration(forms.Form, CommonPropertiesExtension): ad = 'Active Directory' domains = api.service_list_by_type(request, environment_id, ad) - self.fields['iis_domain'].choices = [("", "")] + \ + self.fields['iis_domain'].choices = [("", "Not in domain")] + \ [(domain.name, domain.name) for domain in domains] CommonPropertiesExtension.__init__(self) class WebFarmExtension(forms.Form): - instance_count = forms.IntegerField(label=_('Instance Count'), - required=True, - min_value=1, - max_value=10000, - initial=1) - lb_port = forms.IntegerField(label=_('Load Balancer port'), - required=True, - min_value=1, - max_value=65536, - initial=80) + instance_count = forms.IntegerField( + label=_('Instance Count'), + min_value=1, + max_value=10000, + initial=1) + + lb_port = forms.IntegerField( + label=_('Load Balancer port'), + min_value=1, + max_value=65536, + initial=80) class WizardFormAspNetAppConfiguration(WizardFormIISConfiguration, CommonPropertiesExtension): git_repo_re = re.compile(r'(\w+://)(.+@)*([\w\d\.]+)(:[\d]+)?/*(.*)', re.IGNORECASE) - validate_git = RegexValidator(git_repo_re, - _('Enter correct git repository url'), - 'invalid') + validate_git = RegexValidator( + git_repo_re, _('Enter correct git repository url'), 'invalid') - repository = forms.CharField(label=_('Git repository'), - required=True, - validators=[validate_git], - error_messages= - {'invalid': validate_git.message}) + repository = forms.CharField( + label=_('Git repository'), + validators=[validate_git], + error_messages={'invalid': validate_git.message}) class WizardFormIISFarmConfiguration(WizardFormIISConfiguration, diff --git a/muranodashboard/templates/_services_tabs.html b/muranodashboard/templates/_services_tabs.html index b79e1f96a..980db3c00 100644 --- a/muranodashboard/templates/_services_tabs.html +++ b/muranodashboard/templates/_services_tabs.html @@ -27,7 +27,7 @@
{% if wizard.steps.prev %} -

{{ service_type }} Service

+

{{ service_type }} Service

{% if service_type == 'Active Directory' %}

{% trans "Now you can set the parameters for Active Directory Service." %}

{% trans "You can create few Active Directory instances, in this case will be created one Main Active Directory server and few Secondary Active Directory servers." %}

@@ -36,22 +36,22 @@

{% trans "Now you can set parameters for ASP.NET Application Service." %}

{% trans "ASP.NET applications are installed to IIS Web Server" %}

{% trans "Please, set the complex password for local administrator account." %}

-

{% trans "Also, you can add this IIS server to the existing domain and configure credentials for domain user." %}

+

{% trans "Also, service can be added to the existing domain." %}

{% elif service_type == 'ASP.NET Farm' %}

{% trans "Now you can set parameters for ASP.NET Application Farm Service." %}

{% trans "ASP.NET applications are installed to IIS Web Server" %}

{% trans "Please, set the complex password for local administrator account." %}

-

{% trans "Also, you can add this IIS server to the existing domain and configure credentials for domain user." %}

- {% elif service_type == 'ASP.NET Farm' %} +

{% trans "Also, service can be added to the existing domain." %}

+ {% elif service_type == 'ISS Farm' %}

{% trans "Now you can set parameters for IIS Farm Service." %}

{% trans "The IIS Service - it is the server with complex Internet Information Services infrastructure, which included to the domain infrasructure." %}

{% trans "Please, set the complex password for local administrator account." %}

-

{% trans "Also, you can add this IIS server to the existing domain and configure credentials for domain user." %}

+

{% trans "Also, service can be added to the existing domain." %}

{% else %}

{% trans "Now you can set parameters for IIS Service." %}

{% trans "The IIS Service - it is the server with complex Internet Information Services infrastructure, which included to the domain infrasructure." %}

{% trans "Please, set the complex password for local administrator account." %}

-

{% trans "Also, you can add this IIS server to the existing domain and configure credentials for domain user." %}

+

{% trans "Also, service can be added to the existing domain." %}

{% endif %}

{% trans "You can specify a template for a host-name format. Use # character for a sequential number like myhost#." %}