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