Commit 0231b41f authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

Revert "wheezy: fix is_safe attribute of template filters"

This reverts commit 730fb3b0a0607bba95b90db1c6154cb7febb9187. This
commit is reverted because it breaks compatibility with Django 1.2. This
should be applied for Synnefo 0.15.
parent 43b39fbb
......@@ -2,7 +2,6 @@ from django import template
register = template.Library()
@register.filter(name="vm_public_ip")
def vm_public_ip(vm):
"""
......@@ -24,9 +23,7 @@ VM_STATE_CSS_MAP = {
'ACTIVE': 'success',
'DESTROYED': 'inverse'
}
@register.filter(name="object_status_badge", is_safe=True)
@register.filter(name="object_status_badge")
def object_status_badge(vm_or_net):
"""
Return a span badge styled based on the vm current status
......@@ -41,8 +38,9 @@ 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", is_safe=True)
@register.filter(name="network_deleted_badge")
def network_deleted_badge(network):
"""
Return a span badge styled based on the vm current status
......@@ -52,16 +50,18 @@ 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", is_safe=True)
@register.filter(name="get_os")
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", is_safe=True)
@register.filter(name="network_vms")
def network_vms(network, account, show_deleted=False):
vms = []
nics = network.nics.filter(machine__userid=account)
......@@ -71,6 +71,7 @@ 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):
......@@ -80,8 +81,7 @@ def network_nics(network, account, show_deleted=False):
nics = nics.filter(machine__deleted=False).distinct()
return nics
@register.filter(name="backend_info", is_safe=True)
@register.filter(name="backend_info")
def backend_info(vm):
content = ""
backend = vm.backend
......@@ -96,3 +96,5 @@ 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