Fix help_msg and errors view.
Change-Id: Ib0aba3bf1c5b87b3db4a79fcb5ea8a4dcea8e2d0
This commit is contained in:
parent
8fa36d8807
commit
f7d275ad3b
|
@ -14,10 +14,11 @@
|
|||
|
||||
import logging
|
||||
|
||||
import re
|
||||
from django import forms
|
||||
from django.core.validators import RegexValidator
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
import re
|
||||
|
||||
from muranodashboard.panel import api
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -33,17 +34,29 @@ class PasswordField(forms.CharField):
|
|||
number and one special character'), 'invalid')
|
||||
|
||||
def __init__(self, label, *args, **kwargs):
|
||||
help_text = kwargs.get('help_text')
|
||||
if not help_text:
|
||||
help_text = _('Enter a complex password with at least one letter, \
|
||||
one number and one special character')
|
||||
|
||||
error_messages = {
|
||||
'invalid': self.validate_password.message}
|
||||
err_msg = kwargs.get('error_messages')
|
||||
if err_msg:
|
||||
if err_msg.get('required'):
|
||||
error_messages['required'] = err_msg.get('required')
|
||||
|
||||
super(PasswordField, self).__init__(
|
||||
min_length=7,
|
||||
max_length=255,
|
||||
validators=[self.validate_password],
|
||||
label=label,
|
||||
error_messages={'invalid': self.validate_password.message},
|
||||
error_messages=error_messages,
|
||||
help_text=help_text,
|
||||
widget=forms.PasswordInput(render_value=False))
|
||||
|
||||
|
||||
class WizardFormServiceType(forms.Form):
|
||||
|
||||
ad_service = ('Active Directory', 'Active Directory')
|
||||
iis_service = ('IIS', 'Internet Information Services')
|
||||
asp_service = ('ASP.NET Application', 'ASP.NET Application')
|
||||
|
@ -66,20 +79,23 @@ class WizardFormConfiguration(forms.Form):
|
|||
|
||||
class ServiceConfigurationForm(forms.Form):
|
||||
def clean(self):
|
||||
def compare(pwd1, pwd2, admin=True):
|
||||
if pwd1 != pwd2:
|
||||
pwd_type = 'Administrator'
|
||||
if not admin:
|
||||
pwd_type = 'Recovery'
|
||||
raise forms.ValidationError(
|
||||
_(' %s passwords don\'t match' % pwd_type))
|
||||
|
||||
form_data = self.cleaned_data
|
||||
admin_pwd1 = form_data.get('adm_password')
|
||||
admin_pwd2 = form_data.get('adm_password2')
|
||||
|
||||
if admin_pwd1 != admin_pwd2:
|
||||
raise forms.ValidationError(
|
||||
_('Administrator passwords don\'t match'))
|
||||
compare(admin_pwd1, admin_pwd2)
|
||||
|
||||
recovery_pwd1 = form_data.get('recovery_password')
|
||||
if recovery_pwd1:
|
||||
recovery_pwd2 = form_data.get('recovery_password2')
|
||||
if recovery_pwd1 != recovery_pwd2:
|
||||
raise forms.ValidationError(
|
||||
_('Recovery passwords don\'t match'))
|
||||
compare(recovery_pwd1, recovery_pwd2, admin=False)
|
||||
|
||||
return self.cleaned_data
|
||||
|
||||
|
@ -88,7 +104,13 @@ class CommonPropertiesExtension(object):
|
|||
def __init__(self):
|
||||
self.fields.insert(
|
||||
len(self.fields), 'unit_name_template',
|
||||
forms.CharField(label=_('Hostname template'), required=False))
|
||||
forms.CharField(
|
||||
label=_('Hostname template'),
|
||||
required=False,
|
||||
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.\
|
||||
Enter valid symbols'))
|
||||
|
||||
for field, instance in self.fields.iteritems():
|
||||
if not instance.required:
|
||||
|
@ -100,30 +122,45 @@ class WizardFormADConfiguration(ServiceConfigurationForm,
|
|||
domain_name_re = re.compile(
|
||||
r'^[a-zA-Z0-9][a-zA-Z0-9.-]*[a-zA-Z0-9]$')
|
||||
validate_domain_name = RegexValidator(domain_name_re,
|
||||
_(u'Enter a valid domain name: \
|
||||
just letters, numbers, dashes and \
|
||||
one dot are allowed'), 'invalid')
|
||||
_(u'Name should not contain anything\
|
||||
but letters, numbers and dashes \
|
||||
and should not start with a dash'),
|
||||
'invalid')
|
||||
|
||||
dc_name = forms.CharField(
|
||||
label=_('Domain Name'),
|
||||
min_length=2,
|
||||
max_length=64,
|
||||
validators=[validate_domain_name],
|
||||
error_messages={'invalid': validate_domain_name.message})
|
||||
error_messages={'invalid': validate_domain_name.message},
|
||||
help_text=_('Just letters, numbers and dashes are allowed. \
|
||||
A dot can be used to create subdomains'))
|
||||
|
||||
dc_count = forms.IntegerField(
|
||||
label=_('Instance Count'),
|
||||
min_value=1,
|
||||
max_value=100,
|
||||
initial=1)
|
||||
initial=1,
|
||||
help_text=_('Enter an integer value between 1 and 100'))
|
||||
|
||||
adm_password = PasswordField(_('Administrator password'))
|
||||
adm_password2 = \
|
||||
PasswordField(_('Confirm password'), error_messages=CONFIRM_ERR_DICT)
|
||||
adm_password = PasswordField(
|
||||
_('Administrator password'))
|
||||
|
||||
recovery_password = PasswordField(_('Recovery password'))
|
||||
recovery_password2 = \
|
||||
PasswordField(_('Confirm password'), error_messages=CONFIRM_ERR_DICT)
|
||||
adm_password2 = PasswordField(
|
||||
_('Confirm password'),
|
||||
help_text=_('Retype your password'),
|
||||
error_messages=CONFIRM_ERR_DICT)
|
||||
|
||||
recovery_password = PasswordField(
|
||||
_('Recovery password'),
|
||||
help_text=_('Enter a complex password with at least one letter, one \
|
||||
number and one special character. It\'s better to set a \
|
||||
password different from Administrator password'))
|
||||
|
||||
recovery_password2 = PasswordField(
|
||||
_('Confirm password'),
|
||||
error_messages=CONFIRM_ERR_DICT,
|
||||
help_text=_('Retype your password'))
|
||||
|
||||
def __init__(self, request, *args, **kwargs):
|
||||
super(WizardFormADConfiguration, self).__init__(*args, **kwargs)
|
||||
|
@ -135,22 +172,30 @@ class WizardFormIISConfiguration(ServiceConfigurationForm,
|
|||
name_re = re.compile(r'^[-\w]+$')
|
||||
validate_name = RegexValidator(name_re,
|
||||
_(u'Just letters, numbers, underscores \
|
||||
or hyphens are allowed.'), 'invalid')
|
||||
and hyphens are allowed.'), 'invalid')
|
||||
|
||||
iis_name = forms.CharField(
|
||||
label=_('Service Name'),
|
||||
min_length=2,
|
||||
max_length=64,
|
||||
validators=[validate_name],
|
||||
error_messages={'invalid': validate_name.message})
|
||||
error_messages={'invalid': validate_name.message},
|
||||
help_text=_('Just letters, numbers, underscores \
|
||||
and hyphens are allowed'))
|
||||
|
||||
adm_password = PasswordField(_('Administrator password'))
|
||||
adm_password2 = \
|
||||
PasswordField(_('Confirm password'), error_messages=CONFIRM_ERR_DICT)
|
||||
adm_password = PasswordField(
|
||||
_('Administrator password'),
|
||||
help_text=_('Enter a complex password with at least one letter, one \
|
||||
number and one special character'))
|
||||
adm_password2 = PasswordField(
|
||||
_('Confirm password'),
|
||||
error_messages=CONFIRM_ERR_DICT,
|
||||
help_text=_('Retype your password'))
|
||||
|
||||
iis_domain = forms.ChoiceField(
|
||||
label=_('Domain'),
|
||||
required=False)
|
||||
required=False,
|
||||
help_text=_('You can create service inside existing domain'))
|
||||
|
||||
def __init__(self, request, *args, **kwargs):
|
||||
super(WizardFormIISConfiguration, self).__init__(*args, **kwargs)
|
||||
|
@ -171,14 +216,17 @@ class WebFarmExtension(ServiceConfigurationForm):
|
|||
instance_count = forms.IntegerField(
|
||||
label=_('Instance Count'),
|
||||
min_value=1,
|
||||
max_value=10000,
|
||||
initial=1)
|
||||
max_value=100,
|
||||
initial=1,
|
||||
help_text=_('Enter an integer value between 1 and 100'))
|
||||
|
||||
lb_port = forms.IntegerField(
|
||||
label=_('Load Balancer port'),
|
||||
min_value=1,
|
||||
max_value=65536,
|
||||
initial=80)
|
||||
initial=80,
|
||||
help_text=_('Enter an integer value. It should be non used port number\
|
||||
from 1 to 65536'))
|
||||
|
||||
|
||||
class WizardFormAspNetAppConfiguration(WizardFormIISConfiguration,
|
||||
|
@ -191,7 +239,8 @@ class WizardFormAspNetAppConfiguration(WizardFormIISConfiguration,
|
|||
repository = forms.CharField(
|
||||
label=_('Git repository'),
|
||||
validators=[validate_git],
|
||||
error_messages={'invalid': validate_git.message})
|
||||
error_messages={'invalid': validate_git.message},
|
||||
help_text='Enter a valid git repository URL')
|
||||
|
||||
|
||||
class WizardFormIISFarmConfiguration(WizardFormIISConfiguration,
|
||||
|
|
|
@ -129,7 +129,6 @@ class DeployEnvironment(tables.BatchAction):
|
|||
|
||||
def allowed(self, request, environment):
|
||||
status = getattr(environment, 'status', None)
|
||||
|
||||
if status not in [STATUS_ID_DEPLOYING] and environment.has_services:
|
||||
return True
|
||||
else:
|
||||
|
|
|
@ -44,7 +44,7 @@ LOG = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class Wizard(ModalFormMixin, SessionWizardView):
|
||||
template_name = 'services_tabs.html'
|
||||
template_name = 'create_service_wizard.html'
|
||||
|
||||
def done(self, form_list, **kwargs):
|
||||
link = self.request.__dict__['META']['HTTP_REFERER']
|
||||
|
@ -151,14 +151,13 @@ class IndexView(tables.DataTableView):
|
|||
template_name = 'index.html'
|
||||
|
||||
def get_data(self):
|
||||
environments = []
|
||||
try:
|
||||
environments = api.environments_list(self.request)
|
||||
except CommunicationError:
|
||||
environments = []
|
||||
messages.error(self.request, 'Could not connect to Murano API '
|
||||
'Service, check connection details.')
|
||||
except HTTPInternalServerError:
|
||||
environments = []
|
||||
messages.error(self.request, 'Environment doesn\'t exist')
|
||||
|
||||
return environments
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
{% extends "horizon/common/_modal_form.html" %}
|
||||
{% load i18n horizon humanize %}
|
||||
|
||||
{% block form_action %}{% url horizon:project:murano:create %}?{{ request.POST.urlencode }}{% endblock %}
|
||||
|
||||
{% block modal_id %}create_service{% endblock %}
|
||||
{% block modal-header %}{% trans "Create Service" %}{% endblock %}
|
||||
|
||||
{% block modal-body %}
|
||||
<div class="left">
|
||||
<br>
|
||||
{% if wizard.steps.next %}
|
||||
<br><br><br>
|
||||
{% endif %}
|
||||
|
||||
<table>
|
||||
{{ wizard.management_form }}
|
||||
{% if wizard.form.forms %}
|
||||
{{ wizard.form.management_form }}
|
||||
{% for form in wizard.form.forms %}
|
||||
{{ form }}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<fieldset>
|
||||
{% include "_horizon_form_fields.html" %}
|
||||
</fieldset>
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
<div class="right">
|
||||
{% if wizard.steps.prev %}
|
||||
<h3>{{ service_type }} Service</h3>
|
||||
<p>{% blocktrans %} Specify parameters for the {{ service_type }} Service.{% endblocktrans %}</p>
|
||||
{% if service_type == 'Active Directory' %}
|
||||
<p>{% blocktrans %} You can create several Active Directory instances by setting instance number larger than one.
|
||||
In this case will be created one primary Domain Controller and a few secondary DCs. {% endblocktrans %}</p>
|
||||
<p>{% blocktrans %} DNS server will be automatically set up on each of the Domain Controller instances. {% endblocktrans %}</p>
|
||||
|
||||
{% elif service_type == 'ASP.NET Application' %}
|
||||
<p>{% blocktrans %} ASP.NET application is installed onto one IIS Web Server. {% endblocktrans %}</p>
|
||||
<p>{% blocktrans %} This service can be added to an existing domain. {% endblocktrans %}</p>
|
||||
|
||||
{% elif service_type == 'ASP.NET Farm' %}
|
||||
<p>{% blocktrans %} ASP.NET application is installed on a number IIS Web Servers, and load balancing is configured. {% endblocktrans %}</p>
|
||||
<p>{% blocktrans %}This service can be added to an existing domain. {% endblocktrans %}</p>
|
||||
|
||||
{% elif service_type == 'ISS Farm' %}
|
||||
<p>{% blocktrans %} A load-balanced array of IIS servers. {% endblocktrans %}</p>
|
||||
<p>{% blocktrans %} This service can be added to an existing domain. {% endblocktrans %}</p>
|
||||
|
||||
{% else %}
|
||||
<p>{% blocktrans %} One IIS Server. {% endblocktrans %}</p>
|
||||
<p>{% blocktrans %} This service can be added to an existing domain. {% endblocktrans %}</p>
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
<h3>{% trans "Description" %}:</h3>
|
||||
<p>{% blocktrans %} The Active Directory Service includes one primary and optionally a few secondary Domain Controllers, with DNS service {% endblocktrans %}</p>
|
||||
<p>{% blocktrans %} The Internet Information Service sets up an IIS server and joins it into an existing domain {% endblocktrans %}</p>
|
||||
<p>{% blocktrans %} The ASP.NET Application Service installs custom application onto one IIS Web Server {% endblocktrans %}</p>
|
||||
<p>{% blocktrans %} The IIS Farm Service sets up a load-balanced set of IIS servers {% endblocktrans %}</p>
|
||||
<p>{% blocktrans %} The ASP.NET Application Service installs a custom application on a load-balanced array of IIS servers {% endblocktrans %}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block modal-footer %}
|
||||
{% if wizard.steps.prev %}
|
||||
<input type="submit" class="btn btn-primary pull-right" value="{% trans 'Create' %}"/>
|
||||
{% else %}
|
||||
<button name="wizard_goto_step" class="btn btn-small" type="submit" value="{{ wizard.steps.next }}">{% trans "Next >" %}</button>
|
||||
{% endif %}
|
||||
{% endblock %}
|
|
@ -0,0 +1,22 @@
|
|||
{% for hidden in wizard.form.hidden_fields %}
|
||||
{{ hidden }}
|
||||
{% endfor %}
|
||||
{% if wizard.form.non_field_errors %}
|
||||
<div class="alert alert-message alert-error">
|
||||
{{ wizard.form.non_field_errors }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% for field in wizard.form.visible_fields %}
|
||||
<div class="control-group form-field clearfix{% if field.errors %} error{% endif %}">
|
||||
{{ field.label_tag }}
|
||||
{% if field.errors %}
|
||||
{% for error in field.errors %}
|
||||
<span class="help-inline">{{ error }}</span>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<span class="help-block">{{ field.help_text }}</span>
|
||||
<div class="input">
|
||||
{{ field }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
|
@ -1,73 +0,0 @@
|
|||
{% extends "horizon/common/_modal_form.html" %}
|
||||
{% load i18n horizon humanize %}
|
||||
|
||||
{% block form_action %}{% url horizon:project:murano:create %}?{{ request.POST.urlencode }}{% endblock %}
|
||||
|
||||
{% block modal_id %}create_service{% endblock %}
|
||||
{% block modal-header %}{% trans "Create Service" %}{% endblock %}
|
||||
|
||||
{% block modal-body %}
|
||||
<div class="left">
|
||||
<br>
|
||||
{% if wizard.steps.next %}
|
||||
<br><br><br>
|
||||
{% endif %}
|
||||
<table>
|
||||
{{ wizard.management_form }}
|
||||
{% if wizard.form.forms %}
|
||||
{{ wizard.form.management_form }}
|
||||
{% for form in wizard.form.forms %}
|
||||
{{ form }}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{{ wizard.form }}
|
||||
{% endif %}
|
||||
{{ wizard.form.forms }}
|
||||
</table>
|
||||
</div>
|
||||
<div class="right">
|
||||
{% if wizard.steps.prev %}
|
||||
<h3>{{ service_type }} Service</h3>
|
||||
{% if service_type == 'Active Directory' %}
|
||||
<p>{% trans "Now you can set the parameters for Active Directory Service." %}</p>
|
||||
<p>{% 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." %}</p>
|
||||
<p>{% trans "The DNS service will be automatically created on each Active Directory servers." %}</p>
|
||||
{% elif service_type == 'ASP.NET Application' %}
|
||||
<p>{% trans "Now you can set parameters for ASP.NET Application Service." %}</p>
|
||||
<p>{% trans "ASP.NET applications are installed to IIS Web Server" %}</p>
|
||||
<p>{% trans "Please, set the complex password for local administrator account." %}</p>
|
||||
<p>{% trans "Also, service can be added to the existing domain." %}</p>
|
||||
{% elif service_type == 'ASP.NET Farm' %}
|
||||
<p>{% trans "Now you can set parameters for ASP.NET Application Farm Service." %}</p>
|
||||
<p>{% trans "ASP.NET applications are installed to IIS Web Server" %}</p>
|
||||
<p>{% trans "Please, set the complex password for local administrator account." %}</p>
|
||||
<p>{% trans "Also, service can be added to the existing domain." %}</p>
|
||||
{% elif service_type == 'ISS Farm' %}
|
||||
<p>{% trans "Now you can set parameters for IIS Farm Service." %}</p>
|
||||
<p>{% trans "The IIS Service - it is the server with complex Internet Information Services infrastructure, which included to the domain infrasructure." %}</p>
|
||||
<p>{% trans "Please, set the complex password for local administrator account." %}</p>
|
||||
<p>{% trans "Also, service can be added to the existing domain." %}</p>
|
||||
{% else %}
|
||||
<p>{% trans "Now you can set parameters for IIS Service." %}</p>
|
||||
<p>{% trans "The IIS Service - it is the server with complex Internet Information Services infrastructure, which included to the domain infrasructure." %}</p>
|
||||
<p>{% trans "Please, set the complex password for local administrator account." %}</p>
|
||||
<p>{% trans "Also, service can be added to the existing domain." %}</p>
|
||||
{% endif %}
|
||||
<p>{% trans "You can specify a template for a host-name format. Use # character for a sequential number like myhost#." %}</p>
|
||||
|
||||
{% else %}
|
||||
<h3>{% trans "Description" %}:</h3>
|
||||
<p>{% trans "Now you can select the type of the service." %}</p>
|
||||
<p>{% trans "The Active Directory Service allows to configure Domain Controllers with Active Directory and DNS infrastructure. You can create one Main Domain Controller and few Secondary Domain Controllers." %}</p>
|
||||
<p>{% trans "The Internet Information Services allows to configure IIS servers, which can be included to the existing domain infrastructure." %}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block modal-footer %}
|
||||
{% if wizard.steps.prev %}
|
||||
<input type="submit" class="btn btn-primary pull-right" value="{% trans 'Create' %}"/>
|
||||
{% else %}
|
||||
<button name="wizard_goto_step" class="btn btn-small" type="submit" value="{{ wizard.steps.next }}">{% trans "Next >" %}</button>
|
||||
{% endif %}
|
||||
{% endblock %}
|
|
@ -0,0 +1,12 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block title %}{% trans "Add Rule" %}{% endblock %}
|
||||
|
||||
{% block page_header %}
|
||||
{% include "horizon/common/_page_header.html" with title=_("Create Service") %}
|
||||
{% endblock page_header %}
|
||||
|
||||
{% block main %}
|
||||
{% include '_create_service_wizard.html' %}
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue