Skip to content

Commit

Permalink
Ensure "Add Interface" form in Admin Panel works
Browse files Browse the repository at this point in the history
This commit add new templates for interface add/delete operations
in admin panel to make sure the original page is displayed after
adding a router interface successfully.

It also changes the following:
- Update the help message in "Add Interface" and "Set Gateway" forms
  (both in project and admin panels)
- Fixes a issue that Project router detail was displayed after setting
  an external gateway to a router in admin panel.
  Admin router detail is expected to display
- Make sure a router name is displayed in router detail in admin panel.

Fixes Bug #1131177

Change-Id: I9728cb68972977f868549b61979d9c779cd9fd4e
  • Loading branch information
amotoki committed Feb 25, 2013
1 parent 7d13abc commit 0e542cb
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 10 deletions.
Expand Up @@ -34,6 +34,7 @@ class AddInterfaceView(views.AddInterfaceView):

class SetGatewayView(views.SetGatewayView):
form_class = SetGatewayForm
template_name = 'admin/routers/ports/setgateway.html'
success_url = 'horizon:admin:routers:detail'
failure_url = 'horizon:admin:routers:detail'

Expand Down
@@ -1,11 +1,11 @@
{% load i18n sizeformat parse_date %}

<h3>{% trans "Router Overview" %}: {{router.display_name }}</h3>
<h3>{% trans "Router Overview" %}: {{router.name }}</h3>

<div class="info detail">
<dl>
<dt>{% trans "Name" %}</dt>
<dd>{{ router.display_name }}</dd>
<dd>{{ router.name|default:"None" }}</dd>
<dt>{% trans "ID" %}</dt>
<dd>{{ router.id }}</dd>
<dt>{% trans "Status" %}</dt>
Expand Down
@@ -0,0 +1,25 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}

{% block form_id %}add_interface_form{% endblock %}
{% block form_action %}{% url horizon:admin:routers:addinterface router.id %}
{% endblock %}

{% block modal-header %}{% trans "Add Interface" %}{% 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 "You can connect a specified subnet to the router." %}</p>
</div>
{% endblock %}

{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Add interface" %}" />
<a href="{% url horizon:admin:routers:detail router.id %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}
@@ -0,0 +1,25 @@
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}

{% block form_id %}setgateway_form{% endblock %}
{% block form_action %}{% url horizon:admin:routers:setgateway router.id %}
{% endblock %}

{% block modal-header %}{% trans "Set Gateway" %}{% 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 "You can connect a specified external network to the router. The external network is regarded as a default route of the router and the router acts as a gateway for external connectivity." %}</p>
</div>
{% endblock %}

{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Set Gateway" %}" />
<a href="{% url horizon:admin:routers:detail router.id %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}
@@ -0,0 +1,11 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Add Interface" %}{% endblock %}

{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Add Interface") %}
{% endblock page_header %}

{% block main %}
{% include "admin/routers/ports/_create.html" %}
{% endblock %}
@@ -0,0 +1,11 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Set Gateway" %}{% endblock %}

{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Set Gateway") %}
{% endblock page_header %}

{% block main %}
{% include "admin/routers/ports/_setgateway.html" %}
{% endblock %}
10 changes: 8 additions & 2 deletions openstack_dashboard/dashboards/project/routers/ports/forms.py
Expand Up @@ -28,7 +28,10 @@


class AddInterface(forms.SelfHandlingForm):
subnet_id = forms.ChoiceField(label=_("Subnet ID"), required=False)
subnet_id = forms.ChoiceField(label=_("Subnet"), required=False)
router_name = forms.CharField(label=_("Router Name"),
widget=forms.TextInput(
attrs={'readonly': 'readonly'}))
router_id = forms.CharField(label=_("Router ID"),
widget=forms.TextInput(
attrs={'readonly': 'readonly'}))
Expand Down Expand Up @@ -84,7 +87,10 @@ def handle(self, request, data):


class SetGatewayForm(forms.SelfHandlingForm):
network_id = forms.ChoiceField(label=_("Network ID"), required=False)
network_id = forms.ChoiceField(label=_("External Network"), required=False)
router_name = forms.CharField(label=_("Router Name"),
widget=forms.TextInput(
attrs={'readonly': 'readonly'}))
router_id = forms.CharField(label=_("Router ID"),
widget=forms.TextInput(
attrs={'readonly': 'readonly'}))
Expand Down
Expand Up @@ -37,9 +37,9 @@ def get_device_owner(port):

class SetGateway(tables.LinkAction):
name = "setgateway"
verbose_name = _("Add Gateway Interface")
verbose_name = _("Set Gateway")
url = "horizon:project:routers:setgateway"
classes = ("ajax-modal", "btn-camera")
classes = ("ajax-modal", "btn-create")

def get_link_url(self, datum=None):
router_id = self.table.kwargs['router_id']
Expand Down
Expand Up @@ -5,7 +5,7 @@
{% block form_action %}{% url horizon:project:routers:addinterface router.id %}
{% endblock %}

{% block modal-header %}{% trans "Add interface" %}{% endblock %}
{% block modal-header %}{% trans "Add Interface" %}{% endblock %}

{% block modal-body %}
<div class="left">
Expand All @@ -15,7 +15,7 @@
</div>
<div class="right">
<h3>{% trans "Description" %}:</h3>
<p>{% trans "You can add interface to the network with subnet_id." %}</p>
<p>{% trans "You can connect a specified subnet to the router." %}</p>
</div>
{% endblock %}

Expand Down
Expand Up @@ -5,7 +5,7 @@
{% block form_action %}{% url horizon:project:routers:setgateway router.id %}
{% endblock %}

{% block modal-header %}{% trans "Add Gateway Interface" %}{% endblock %}
{% block modal-header %}{% trans "Set Gateway" %}{% endblock %}

{% block modal-body %}
<div class="left">
Expand All @@ -15,7 +15,7 @@
</div>
<div class="right">
<h3>{% trans "Description" %}:</h3>
<p>{% trans "You can add inteface for Gateway. In this interface, NAT rule of floating IP will be set." %}</p>
<p>{% trans "You can connect a specified external network to the router. The external network is regarded as a default route of the router and the router acts as a gateway for external connectivity." %}</p>
</div>
{% endblock %}

Expand Down
4 changes: 4 additions & 0 deletions openstack_dashboard/dashboards/project/routers/tests.py
Expand Up @@ -140,6 +140,7 @@ def test_router_addinterface(self):
self.mox.ReplayAll()

form_data = {'router_id': router.id,
'router_name': router.name,
'subnet_id': subnet.id}

url = reverse('horizon:%s:routers:addinterface' % self.DASHBOARD,
Expand Down Expand Up @@ -171,6 +172,7 @@ def test_router_addinterface_exception(self):
self.mox.ReplayAll()

form_data = {'router_id': router.id,
'router_name': router.name,
'subnet_id': subnet.id}

url = reverse('horizon:%s:routers:addinterface' % self.DASHBOARD,
Expand Down Expand Up @@ -198,6 +200,7 @@ def test_router_add_gateway(self):
self.mox.ReplayAll()

form_data = {'router_id': router.id,
'router_name': router.name,
'network_id': network.id}

url = reverse('horizon:%s:routers:setgateway' % self.DASHBOARD,
Expand Down Expand Up @@ -225,6 +228,7 @@ def test_router_add_gateway_exception(self):
self.mox.ReplayAll()

form_data = {'router_id': router.id,
'router_name': router.name,
'network_id': network.id}

url = reverse('horizon:%s:routers:setgateway' % self.DASHBOARD,
Expand Down

0 comments on commit 0e542cb

Please sign in to comment.