Merge "Make port status and state translatable"
This commit is contained in:
commit
c9782c0aeb
|
@ -15,7 +15,6 @@
|
|||
import logging
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import pgettext_lazy
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ungettext_lazy
|
||||
|
||||
|
@ -87,12 +86,6 @@ class UpdatePort(policy.PolicyTargetMixin, tables.LinkAction):
|
|||
return reverse(self.url, args=(network_id, port.id))
|
||||
|
||||
|
||||
DISPLAY_CHOICES = (
|
||||
("UP", pgettext_lazy("Admin state of a Network", u"UP")),
|
||||
("DOWN", pgettext_lazy("Admin state of a Network", u"DOWN")),
|
||||
)
|
||||
|
||||
|
||||
class PortsTable(tables.DataTable):
|
||||
name = tables.Column("name_or_id",
|
||||
verbose_name=_("Name"),
|
||||
|
@ -101,10 +94,13 @@ class PortsTable(tables.DataTable):
|
|||
project_tables.get_fixed_ips, verbose_name=_("Fixed IPs"))
|
||||
device_id = tables.Column(
|
||||
project_tables.get_attached, verbose_name=_("Device Attached"))
|
||||
status = tables.Column("status", verbose_name=_("Status"))
|
||||
status = tables.Column(
|
||||
"status",
|
||||
verbose_name=_("Status"),
|
||||
display_choices=project_tables.STATUS_DISPLAY_CHOICES)
|
||||
admin_state = tables.Column("admin_state",
|
||||
verbose_name=_("Admin State"),
|
||||
display_choices=DISPLAY_CHOICES)
|
||||
display_choices=project_tables.DISPLAY_CHOICES)
|
||||
mac_state = tables.Column("mac_state", empty_value=api.neutron.OFF_STATE,
|
||||
verbose_name=_("Mac Learning State"))
|
||||
|
||||
|
|
|
@ -56,6 +56,11 @@ DISPLAY_CHOICES = (
|
|||
("DOWN", pgettext_lazy("Admin state of a Port", u"DOWN")),
|
||||
)
|
||||
|
||||
STATUS_DISPLAY_CHOICES = (
|
||||
("ACTIVE", pgettext_lazy("status of a network port", u"ACTIVE")),
|
||||
("DOWN", pgettext_lazy("status of a network port", u"DOWN")),
|
||||
)
|
||||
|
||||
|
||||
class PortsTable(tables.DataTable):
|
||||
name = tables.Column("name_or_id",
|
||||
|
@ -63,7 +68,9 @@ class PortsTable(tables.DataTable):
|
|||
link="horizon:project:networks:ports:detail")
|
||||
fixed_ips = tables.Column(get_fixed_ips, verbose_name=_("Fixed IPs"))
|
||||
attached = tables.Column(get_attached, verbose_name=_("Attached Device"))
|
||||
status = tables.Column("status", verbose_name=_("Status"))
|
||||
status = tables.Column("status",
|
||||
verbose_name=_("Status"),
|
||||
display_choices=STATUS_DISPLAY_CHOICES)
|
||||
admin_state = tables.Column("admin_state",
|
||||
verbose_name=_("Admin State"),
|
||||
display_choices=DISPLAY_CHOICES)
|
||||
|
|
|
@ -29,6 +29,9 @@ from openstack_dashboard.dashboards.project.networks.ports \
|
|||
from openstack_dashboard.dashboards.project.networks.ports \
|
||||
import tabs as project_tabs
|
||||
|
||||
STATE_DICT = dict(project_tables.DISPLAY_CHOICES)
|
||||
STATUS_DICT = dict(project_tables.STATUS_DISPLAY_CHOICES)
|
||||
|
||||
|
||||
class DetailView(tabs.TabView):
|
||||
tab_group_class = project_tabs.PortDetailTabs
|
||||
|
@ -40,6 +43,10 @@ class DetailView(tabs.TabView):
|
|||
|
||||
try:
|
||||
port = api.neutron.port_get(self.request, port_id)
|
||||
port.admin_state_label = STATE_DICT.get(port.admin_state,
|
||||
port.admin_state)
|
||||
port.status_label = STATUS_DICT.get(port.status,
|
||||
port.status)
|
||||
except Exception:
|
||||
port = []
|
||||
redirect = self.get_redirect_url()
|
||||
|
|
|
@ -30,9 +30,9 @@
|
|||
<dt>{% trans "Mac Address" %}</dt>
|
||||
<dd>{{ port.mac_address|default:_("None") }}</dd>
|
||||
<dt>{% trans "Status" %}</dt>
|
||||
<dd>{{ port.status|default:_("None") }}</dd>
|
||||
<dd>{{ port.status_label|default:_("None") }}</dd>
|
||||
<dt>{% trans "Admin State" %}</dt>
|
||||
<dd>{{ port.admin_state|default:_("None") }}</dd>
|
||||
<dd>{{ port.admin_state_label|default:_("None") }}</dd>
|
||||
{% if port.mac_state %}
|
||||
<dt>{% trans "MAC Learning State" %}</dt>
|
||||
<dd>{{ port.mac_state }}</dd>
|
||||
|
|
Loading…
Reference in New Issue