Avoid invalid links when no policy is associated

ingress/egress_firewall_policy_id of a firewall group can be null.
Previously the firewall group detail page always create a link
even when ingress/egress_firewall_policy_id is null and it leads
to an invalid link.

Change-Id: I491482789385e9d9735ebcafcc5574fc11fdd2ac
This commit is contained in:
Akihiro Motoki 2019-01-13 06:04:26 +09:00
parent 2b7675ea5a
commit 285c481f0d
1 changed files with 8 additions and 0 deletions

View File

@ -16,13 +16,21 @@
<dt>{% trans "Ingress Policy ID" %}</dt>
<dd>
{% if firewall_group.ingress_firewall_policy_id %}
{% url 'horizon:project:firewalls_v2:policydetails' firewall_group.ingress_firewall_policy_id as policy_url %}
<a href="{{ policy_url }}">{{firewall_group.ingress_policy.name|default:firewall_group.ingress_firewall_policy_id }}</a>
{% else %}
{% trans "-" %}
{% endif %}
</dd>
<dt>{% trans "Egress Policy ID" %}</dt>
<dd>
{% if firewall_group.egress_firewall_policy_id %}
{% url 'horizon:project:firewalls_v2:policydetails' firewall_group.egress_firewall_policy_id as policy_url %}
<a href="{{ policy_url }}">{{firewall_group.egress_policy.name|default:firewall_group.egress_firewall_policy_id }}</a>
{% else %}
{% trans "-" %}
{% endif %}
</dd>
<dt>{% trans "Status" %}</dt>