Commit 54ebf9c8 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

wheezy: fix is_safe attribute of template filters

In Django 1.4 'is_safe' and 'needs_autoescape' attributes has been made
keyword arguments of @register.filter
parent edf9616d
......@@ -2,6 +2,7 @@ from django import template
register = template.Library()
@register.filter(name="vm_public_ip")
def vm_public_ip(vm):
"""
......@@ -23,7 +24,9 @@ VM_STATE_CSS_MAP = {
'ACTIVE': 'success',
'DESTROYED': 'inverse'
}
@register.filter(name="object_status_badge")
@register.filter(name="object_status_badge", is_safe=True)
def object_status_badge(vm_or_net):
"""
Return a span badge styled based on the vm current status
......@@ -38,9 +41,8 @@ def object_status_badge(vm_or_net):
deleted_badge = '<span class="badge badge-important">Deleted</span>'
return '%s\n<span class="%s">%s</span>' % (deleted_badge, badge_cls, state)
object_status_badge.is_safe = True
@register.filter(name="network_deleted_badge")
@register.filter(name="network_deleted_badge", is_safe=True)
def network_deleted_badge(network):
"""
Return a span badge styled based on the vm current status
......@@ -50,18 +52,16 @@ def network_deleted_badge(network):
deleted_badge = '<span class="badge badge-important">Deleted</span>'
return deleted_badge
network_deleted_badge.is_safe = True
@register.filter(name="get_os")
@register.filter(name="get_os", is_safe=True)
def get_os(vm):
try:
return vm.metadata.filter(meta_key="OS").get().meta_value
except:
return "unknown"
get_os.is_safe = True
@register.filter(name="network_vms")
@register.filter(name="network_vms", is_safe=True)
def network_vms(network, account, show_deleted=False):
vms = []
nics = network.nics.filter(machine__userid=account)
......@@ -71,7 +71,6 @@ def network_vms(network, account, show_deleted=False):
vms.append(nic.machine)
return vms
network_vms.is_safe = True
@register.filter(name="network_nics")
def network_nics(network, account, show_deleted=False):
......@@ -81,7 +80,8 @@ def network_nics(network, account, show_deleted=False):
nics = nics.filter(machine__deleted=False).distinct()
return nics
@register.filter(name="backend_info")
@register.filter(name="backend_info", is_safe=True)
def backend_info(vm):
content = ""
backend = vm.backend
......@@ -96,5 +96,3 @@ def backend_info(vm):
content += '<dt>Backend ' + field.name + '</dt><dd>' + \
str(getattr(backend, field.name)) + '</dd>'
return content
backend_info.is_safe = True
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 to comment