Instance overview renders erroneous markup

Under Instance Detail | Overview | Meta | Key Name an unclosed </em>
is rendered for an instance launched without an associated key pair.
This seems to be reproducible using Django 1.6.1 in local devstack.
The issue seems to be that Django's implementation of the add filter
has an issue concatenating a string and a function to localize text.
Since that fails and returns an empty string which subsequently is
added to the closing </em> tag, the closing tag is the only thing
that is displayed.

This fix saves the localized value to a variable which is then used
in the add filter.

Closes-Bug: #1423797
Change-Id: I4452ca4a902bbaf19ae5b2bd9bcbe2900069ac3b
This commit is contained in:
Alex Chan 2015-03-13 10:47:30 -07:00
parent 0a45b0ba1c
commit cf152365cd
1 changed files with 3 additions and 2 deletions

View File

@ -107,8 +107,9 @@
<hr class="header_rule">
<dl class="dl-horizontal">
<dt>{% trans "Key Name" %}</dt>
{% with default_key_name="<em>"|add:_("None")|add:"</em>" %}
<dd>{{ instance.key_name|default:default_key_name }}</dd>
{% trans "None" as default_key_name %}
{% with formatted_default_key_name="<em>"|add:default_key_name|add:"</em>" %}
<dd>{{ instance.key_name|default:formatted_default_key_name }}</dd>
{% endwith %}
{% url 'horizon:project:images:images:detail' instance.image.id as image_url %}
<dt>{% trans "Image Name" %}</dt>