From ebe0967e8e55577d5f9ff5577accd2d0db1ae498 Mon Sep 17 00:00:00 2001 From: Ciro Scognamiglio Date: Tue, 25 Feb 2014 19:09:04 +0100 Subject: [PATCH] rest interface: table format --- rest/templates/table-default.html | 32 +++++++++++++++++++++ rest/templates/table-resources.html | 43 +++++++++++++++++++++++++++++ rest/templatetags/__init__.py | 0 rest/templatetags/rest_filters.py | 12 ++++++++ 4 files changed, 87 insertions(+) create mode 100644 rest/templates/table-default.html create mode 100644 rest/templates/table-resources.html create mode 100644 rest/templatetags/__init__.py create mode 100644 rest/templatetags/rest_filters.py 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 -- 2.47.0