Commit a2c5f856 by Kálmán Viktor

Merge branch 'feature-http-forwards-link' into 'master'

Feature Http Forwards Link

Closes #166
parents 1519d326 9e037cf2
{% load i18n %}
{% load network_tags %}
<h2>
<a href="#" id="vm-details-network-add" class="btn btn-success pull-right no-js-hidden">
<i class="icon-plus"></i> {% trans "add interface" %}
......@@ -91,7 +92,7 @@
{% if l.ipv4 %}
<tr>
<td>
{{ l.ipv4.host }}:{{ l.ipv4.port }}
{% display_portforward l %}
</td>
<td><i class="icon-long-arrow-right"></i></td>
<td>
......@@ -123,7 +124,7 @@
{% if l.ipv6 %}
<tr>
<td>
{{ l.ipv6.host }}:{{ l.ipv6.port }}
{% display_portforward l %}
</td>
<td><i class="icon-long-arrow-right"></i></td>
<td>
......
from django import template
register = template.Library()
LINKABLE_PORTS = {80: "http", 8080: "http", 443: "https", 21: "ftp"}
@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.keys():
href = "%s:%d" % (data['host'], data['port'])
return '<a href="%s://%s">%s</a>' % (
LINKABLE_PORTS.get(ports['private']), 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