1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-02 17:06:09 +00:00

fix(interfaces): a link state libvirt reports as unknown is said in words

libvirt names an unknown link state "unknown", which the interfaces
page showed as "Link unknown" in English in every language. It is now
the translated "Link unknown", as when there is no state.
This commit is contained in:
catborise 2026-11-21 20:17:13 +03:00
parent 70b0b42f8d
commit 00a44f7621
2 changed files with 10 additions and 1 deletions

View file

@ -1 +1 @@
{% load i18n %}{# a link state as libvirt reports it: up, down, another (dormant, lowerlayerdown...) or none #}{% if link == "up" %}<span class="badge text-bg-success">{% trans "Link up" %}</span>{% elif link == "down" %}<span class="badge text-bg-secondary">{% trans "Link down" %}</span>{% elif link %}<span class="badge text-bg-light border">{% blocktrans %}Link {{ link }}{% endblocktrans %}</span>{% else %}<span class="badge text-bg-light border">{% trans "Link unknown" %}</span>{% endif %}
{% load i18n %}{# a link state as libvirt reports it: up, down, another (dormant, lowerlayerdown...) or none #}{% if link == "up" %}<span class="badge text-bg-success">{% trans "Link up" %}</span>{% elif link == "down" %}<span class="badge text-bg-secondary">{% trans "Link down" %}</span>{% elif link and link != "unknown" %}<span class="badge text-bg-light border">{% blocktrans %}Link {{ link }}{% endblocktrans %}</span>{% else %}<span class="badge text-bg-light border">{% trans "Link unknown" %}</span>{% endif %}

View file

@ -157,3 +157,12 @@ class UnchangeableHostTestCase(TestCase):
self.assertEqual(response.status_code, 200)
for method in (conn.start_iface, conn.stop_iface, conn.delete_iface):
method.assert_not_called()
class LinkBadgeTestCase(TestCase):
def test_a_link_state_libvirt_calls_unknown_is_said_in_words(self):
from django.template.loader import render_to_string
for link in ("unknown", None):
self.assertIn("Link unknown", render_to_string("link_badge.html", {"link": link}))
self.assertIn("Link dormant", render_to_string("link_badge.html", {"link": "dormant"}))