Commit 90bd13c0 by Kálmán Viktor Committed by Bach Dániel

dashboard: make certain portforwards links

parent ad1519f3
{% load i18n %} {% load i18n %}
{% load network_tags %}
<h2> <h2>
<a href="#" id="vm-details-network-add" class="btn btn-success pull-right no-js-hidden"> <a href="#" id="vm-details-network-add" class="btn btn-success pull-right no-js-hidden">
<i class="icon-plus"></i> {% trans "add interface" %} <i class="icon-plus"></i> {% trans "add interface" %}
...@@ -91,7 +92,7 @@ ...@@ -91,7 +92,7 @@
{% if l.ipv4 %} {% if l.ipv4 %}
<tr> <tr>
<td> <td>
{{ l.ipv4.host }}:{{ l.ipv4.port }} {% display_portforward l %}
</td> </td>
<td><i class="icon-long-arrow-right"></i></td> <td><i class="icon-long-arrow-right"></i></td>
<td> <td>
...@@ -123,7 +124,7 @@ ...@@ -123,7 +124,7 @@
{% if l.ipv6 %} {% if l.ipv6 %}
<tr> <tr>
<td> <td>
{{ l.ipv6.host }}:{{ l.ipv6.port }} {% display_portforward l %}
</td> </td>
<td><i class="icon-long-arrow-right"></i></td> <td><i class="icon-long-arrow-right"></i></td>
<td> <td>
......
from django import template
register = template.Library()
LINKABLE_PORTS = [80, 8080, 443, 8010]
@register.simple_tag(name="display_portforward")
def display_pf(ports):
is_ipv6 = "ipv6" in ports
data = ports["ipv6" if is_ipv6 else "ipv4"]
if ports['private'] in LINKABLE_PORTS:
href = "%s:%d" % (data['host'], data['port'])
return '<a href="http://%s">%s</a>' % (href, href)
return "%s:%d" % (data['host'], data['port'])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment