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 ...@@ -2,7 +2,6 @@ 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):
""" """
...@@ -24,9 +23,7 @@ VM_STATE_CSS_MAP = { ...@@ -24,9 +23,7 @@ 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
...@@ -41,8 +38,9 @@ def object_status_badge(vm_or_net): ...@@ -41,8 +38,9 @@ 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", is_safe=True) @register.filter(name="network_deleted_badge")
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
...@@ -52,16 +50,18 @@ def network_deleted_badge(network): ...@@ -52,16 +50,18 @@ 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", is_safe=True) @register.filter(name="get_os")
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", is_safe=True) @register.filter(name="network_vms")
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,6 +71,7 @@ def network_vms(network, account, show_deleted=False): ...@@ -71,6 +71,7 @@ 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):
...@@ -80,8 +81,7 @@ 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() 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,3 +96,5 @@ def backend_info(vm): ...@@ -96,3 +96,5 @@ 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