Refactor modal forms for Nexus1000v

Refactoring Nexus1000v modals
Based on merged patch: https://review.openstack.org/#/c/123472/

Change-Id: Ib581d90b9be0618642c01afe5f31a083501c040c
Partially-Implements: blueprint form-template-to-view
This commit is contained in:
Rob Cresswell 2015-02-16 17:43:59 +00:00
parent ca1353081a
commit 642791f01d
3 changed files with 23 additions and 49 deletions

View File

@ -1,29 +1,10 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% block form_id %}create_network_profile_form{% endblock %}
{% block form_action %}{% url 'horizon:router:nexus1000v:create_network_profile' %}{% endblock %}
{% block modal_id %}create_network_profile_modal{% endblock %}
{% block modal-header %}{% trans "Create Network Profile" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p><strong>{% trans "Name:" %}</strong> {% blocktrans %} Select a name for your network profile.{% endblocktrans %}</p>
<p><strong>{% trans "Segment Type:" %}</strong> {% blocktrans %} Segment types available are VLAN, Overlay and Trunk.{% endblocktrans %}</p>
<p><strong>{% trans "Segment Sub Type:" %}</strong> {% blocktrans %} Sub types available are for the Overlay and Trunk segments. Available sub-types for Overlay are: Native-VXLAN, Enhanced-VXLAN or 'Other' (eg. GRE) which can be manually inputed as a text parameter for subtype. Available sub-type for Trunk is: VLAN.{% endblocktrans %}</p>
<p><strong>{% trans "Segment Range:" %}</strong> {% blocktrans %} Segment Ranges are 1-4093 for VLAN and above 5000 for Enhanced-VXLAN Overlay.{% endblocktrans %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Create Network Profile" %}" />
<a href="{% url 'horizon:router:nexus1000v:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% block modal-body-right %}
<h3>{% trans "Description:" %}</h3>
<p><strong>{% trans "Name:" %}</strong> {% blocktrans %} Select a name for your network profile.{% endblocktrans %}</p>
<p><strong>{% trans "Segment Type:" %}</strong> {% blocktrans %} Segment types available are VLAN, Overlay and Trunk.{% endblocktrans %}</p>
<p><strong>{% trans "Segment Sub Type:" %}</strong> {% blocktrans %} Sub types available are for the Overlay and Trunk segments. Available sub-types for Overlay are: Native-VXLAN, Enhanced-VXLAN or 'Other' (eg. GRE) which can be manually inputed as a text parameter for subtype. Available sub-type for Trunk is: VLAN.{% endblocktrans %}</p>
<p><strong>{% trans "Segment Range:" %}</strong> {% blocktrans %} Segment Ranges are 1-4093 for VLAN and above 5000 for Enhanced-VXLAN Overlay.{% endblocktrans %}</p>
{% endblock %}

View File

@ -1,25 +1,7 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}
{% block form_id %}update_network_profile_form{% endblock %}
{% block form_action %}{% url 'horizon:router:nexus1000v:update_network_profile' profile_id %}{% endblock %}
{% block modal-header %}{% trans "Edit Network Profile" %}{% 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 "Edit the network profile to update name, segment range or multicast IP range." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save Changes" %}" />
<a href="{% url 'horizon:router:nexus1000v:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>
{% block modal-body-right %}
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Edit the network profile to update name, segment range or multicast IP range." %}</p>
{% endblock %}

View File

@ -12,7 +12,8 @@
import logging
from django.core import urlresolvers
from django.core.urlresolvers import reverse
from django.core.urlresolvers import reverse_lazy
from django.utils import datastructures
from django.utils.translation import ugettext_lazy as _
@ -102,22 +103,32 @@ class IndexView(tables.MultiTableView):
class CreateNetworkProfileView(forms.ModalFormView):
form_class = profileforms.CreateNetworkProfile
form_id = "create_network_profile_form"
modal_header = _("Create Network Profile")
template_name = 'router/nexus1000v/create_network_profile.html'
success_url = urlresolvers.reverse_lazy('horizon:router:nexus1000v:index')
submit_label = _("Create Network Profile")
submit_url = "horizon:router:nexus1000v:create_network_profile"
success_url = reverse_lazy('horizon:router:nexus1000v:index')
page_title = _("Create Network Profile")
class UpdateNetworkProfileView(forms.ModalFormView):
form_class = profileforms.UpdateNetworkProfile
form_id = "update_network_profile_form"
modal_header = _("Edit Network Profile")
template_name = 'router/nexus1000v/update_network_profile.html'
context_object_name = 'network_profile'
success_url = urlresolvers.reverse_lazy('horizon:router:nexus1000v:index')
submit_label = _("Save Changes")
submit_url = "horizon:router:nexus1000v:update_network_profile"
success_url = reverse_lazy('horizon:router:nexus1000v:index')
page_title = _("Update Network Profile")
def get_context_data(self, **kwargs):
context = super(UpdateNetworkProfileView,
self).get_context_data(**kwargs)
context["profile_id"] = self.kwargs['profile_id']
args = (self.kwargs['profile_id'],)
context['submit_url'] = reverse(self.submit_url, args=args)
return context
@memoized.memoized_method