Merge "Clean modal forms in Orchestration Stacks"

This commit is contained in:
Jenkins 2015-03-17 03:15:23 +00:00 committed by Gerrit Code Review
commit 9d744a4725
5 changed files with 37 additions and 99 deletions

View File

@ -1,28 +1,7 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% block form_id %}select_template{% endblock %}
{% block form_action %}{% url 'horizon:project:stacks:change_template' stack.id %}{% endblock %}
{% block form_attrs %}enctype="multipart/form-data"{% endblock %}
{% block modal-header %}{% trans "Select Template" %}{% endblock %}
{% block modal_id %}select_template_modal{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Use one of the available template source options to specify the template to be used in creating this stack." %}</p>
</div>
{% block modal-body-right %}
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Use one of the available template source options to specify the template to be used in creating this stack." %}</p>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Next" %}" />
<a href="{% url 'horizon:project:stacks:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}

View File

@ -1,26 +1,6 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% block form_id %}launch_stack{% endblock %}
{% block form_action %}{% url 'horizon:project:stacks:launch' %}{% endblock %}
{% block modal-header %}{% trans "Launch Stack" %}{% endblock %}
{% block modal_id %}launch_stack_modal{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Create a new stack with the provided values." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Launch" %}" />
<a href="{% url 'horizon:project:stacks:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% block modal-body-right %}
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Create a new stack with the provided values." %}</p>
{% endblock %}

View File

@ -1,27 +1,7 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% block form_id %}select_template{% endblock %}
{% block form_action %}{% url 'horizon:project:stacks:select_template' %}{% endblock %}
{% block form_attrs %}enctype="multipart/form-data"{% endblock %}
{% block modal-header %}{% trans "Select Template" %}{% endblock %}
{% block modal_id %}select_template_modal{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Use one of the available template source options to specify the template to be used in creating this stack." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Next" %}" />
<a href="{% url 'horizon:project:stacks:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% block modal-body-right %}
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Use one of the available template source options to specify the template to be used in creating this stack." %}</p>
{% endblock %}

View File

@ -1,26 +1,6 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% block form_id %}update_stack{% endblock %}
{% block form_action %}{% url 'horizon:project:stacks:edit_stack' stack.id %}{% endblock %}
{% block modal-header %}{% trans "Update Stack Parameters" %}{% endblock %}
{% block modal_id %}update_stack_modal{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Update a stack with the provided values. Please note that any encrypted parameters, such as passwords, will be reset to default if you do not change them here." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Update" %}" />
<a href="{% url 'horizon:project:stacks:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% block modal-body-right %}
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Update a stack with the provided values. Please note that any encrypted parameters, such as passwords, will be reset to default if you do not change them here." %}</p>
{% endblock %}

View File

@ -86,8 +86,12 @@ class IndexView(tables.DataTableView):
class SelectTemplateView(forms.ModalFormView):
form_class = project_forms.TemplateForm
template_name = 'project/stacks/select_template.html'
modal_header = _("Select Template")
form_id = "select_template"
form_class = project_forms.TemplateForm
submit_label = _("Next")
submit_url = reverse_lazy("horizon:project:stacks:select_template")
success_url = reverse_lazy('horizon:project:stacks:launch')
page_title = _("Select Template")
@ -98,14 +102,20 @@ class SelectTemplateView(forms.ModalFormView):
class ChangeTemplateView(forms.ModalFormView):
form_class = project_forms.ChangeTemplateForm
template_name = 'project/stacks/change_template.html'
modal_header = _("Select Template")
form_id = "change_template"
form_class = project_forms.ChangeTemplateForm
submit_label = _("Next")
submit_url = "horizon:project:stacks:change_template"
cancel_url = reverse_lazy('horizon:project:stacks:index')
success_url = reverse_lazy('horizon:project:stacks:edit_stack')
page_title = _("Change Template")
def get_context_data(self, **kwargs):
context = super(ChangeTemplateView, self).get_context_data(**kwargs)
context['stack'] = self.get_object()
args = (self.get_object().id,)
context['submit_url'] = reverse(self.submit_url, args=args)
return context
@memoized.memoized_method
@ -148,8 +158,12 @@ class PreviewTemplateView(forms.ModalFormView):
class CreateStackView(forms.ModalFormView):
form_class = project_forms.CreateStackForm
template_name = 'project/stacks/create.html'
modal_header = _("Launch Stack")
form_id = "launch_stack"
form_class = project_forms.CreateStackForm
submit_label = _("Launch")
submit_url = reverse_lazy("horizon:project:stacks:launch")
success_url = reverse_lazy('horizon:project:stacks:index')
page_title = _("Launch Stack")
@ -180,8 +194,12 @@ class CreateStackView(forms.ModalFormView):
# edit stack parameters, coming from template selector
class EditStackView(CreateStackView):
form_class = project_forms.EditStackForm
template_name = 'project/stacks/update.html'
modal_header = _("Update Stack Parameters")
form_id = "update_stack"
form_class = project_forms.EditStackForm
submit_label = _("Update")
submit_url = "horizon:project:stacks:edit_stack"
success_url = reverse_lazy('horizon:project:stacks:index')
page_title = _("Update Stack")
@ -197,7 +215,8 @@ class EditStackView(CreateStackView):
def get_context_data(self, **kwargs):
context = super(EditStackView, self).get_context_data(**kwargs)
context['stack'] = self.get_object()['stack']
args = (self.get_object()['stack'].id,)
context['submit_url'] = reverse(self.submit_url, args=args)
return context
@memoized.memoized_method