From: Ciro Scognamiglio Date: Tue, 25 Feb 2014 18:09:04 +0000 (+0100) Subject: rest interface: table format X-Git-Tag: myslice-1.1~303 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=ebe0967e8e55577d5f9ff5577accd2d0db1ae498;p=myslice.git rest interface: table format --- diff --git a/rest/templates/table-default.html b/rest/templates/table-default.html new file mode 100644 index 00000000..79d81948 --- /dev/null +++ b/rest/templates/table-default.html @@ -0,0 +1,32 @@ +{% load rest_filters %} + + + {% for p in properties %} + + {{ p }} + + {% endfor %} + + + +{% for d in data %} + + {% for p in properties %} + +
{{ d|key:p }}
+ + {% endfor %} + +{% endfor %} + + \ No newline at end of file diff --git a/rest/templates/table-resources.html b/rest/templates/table-resources.html new file mode 100644 index 00000000..525b55d8 --- /dev/null +++ b/rest/templates/table-resources.html @@ -0,0 +1,43 @@ + + + + Resource + + + Location + + + + + + + +{% for d in data %} + + +
{{ d.hostname|default:"" }} {{ d.type|default:"" }}
+
{{ d.hrn|default:"" }}
+ + +
{{ d.country|default:"" }}
+
{{ d.location|default:"" }}
+ + +
{{ d.boot_state }}
+
{{ d.network_hrn }}
+ + + +{% endfor %} + + \ No newline at end of file diff --git a/rest/templatetags/__init__.py b/rest/templatetags/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/rest/templatetags/rest_filters.py b/rest/templatetags/rest_filters.py new file mode 100644 index 00000000..bc68393b --- /dev/null +++ b/rest/templatetags/rest_filters.py @@ -0,0 +1,12 @@ +from django import template + +register = template.Library() + +@register.filter(name='key') +def key(d, key_name): + if d[key_name] != None : + return d[key_name] + else : + return "" + +#key = register.filter('key', key) \ No newline at end of file