rest interface: table format
authorCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Tue, 25 Feb 2014 18:09:04 +0000 (19:09 +0100)
committerCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Tue, 25 Feb 2014 18:09:04 +0000 (19:09 +0100)
rest/templates/table-default.html [new file with mode: 0644]
rest/templates/table-resources.html [new file with mode: 0644]
rest/templatetags/__init__.py [new file with mode: 0644]
rest/templatetags/rest_filters.py [new file with mode: 0644]

diff --git a/rest/templates/table-default.html b/rest/templates/table-default.html
new file mode 100644 (file)
index 0000000..79d8194
--- /dev/null
@@ -0,0 +1,32 @@
+{% load rest_filters %}
+<thead>
+<tr>
+       {% for p in properties %}
+       <th>
+               {{ p }}
+       </th>
+       {% endfor %}
+</tr>
+</thead>
+<tbody>
+{% for d in data %}
+<tr>
+       {% for p in properties %}
+       <td>
+               <div class="line1">{{ d|key:p }}</div>
+       </td>
+       {% endfor %}
+</tr>
+{% endfor %}
+</tbody>
+<!-- 
+"component_name",
+ "tags", 
+ "component_id", 
+ "interfaces", 
+ "component_manager_id",
+  "longitude", "country",
+   "exclusive", "hrn", "hardware_types",
+    "slice", "network_hrn",
+     "hostname", "urn", "x", "y", "z", 
+     "initscripts", "location", "latitude", "boot_state", "type" -->
\ No newline at end of file
diff --git a/rest/templates/table-resources.html b/rest/templates/table-resources.html
new file mode 100644 (file)
index 0000000..525b55d
--- /dev/null
@@ -0,0 +1,43 @@
+<thead>
+<tr>
+       <th>
+               Resource
+       </th>
+       <th>
+               Location
+       </th>
+       <th>
+               
+       </th>
+</tr>
+</thead>
+<tbody>
+{% for d in data %}
+<tr>
+       <td>
+               <div class="line1">{{ d.hostname|default:"" }} <span class="detail">{{ d.type|default:"" }}</span></div>
+               <div class="line2">{{ d.hrn|default:"" }}</div>
+       </td>
+       <td>
+               <div class="line1">{{ d.country|default:"" }}</div>
+               <div class="hrn">{{ d.location|default:"" }}</div>
+       </td>
+       <td>
+               <div class="hostname">{{ d.boot_state }}</div>
+               <div class="hrn">{{ d.network_hrn }}</div>
+       </td>
+       
+</tr>
+{% endfor %}
+</tbody>
+<!-- 
+"component_name",
+ "tags", 
+ "component_id", 
+ "interfaces", 
+ "component_manager_id",
+  "longitude", "country",
+   "exclusive", "hrn", "hardware_types",
+    "slice", "network_hrn",
+     "hostname", "urn", "x", "y", "z", 
+     "initscripts", "location", "latitude", "boot_state", "type" -->
\ No newline at end of file
diff --git a/rest/templatetags/__init__.py b/rest/templatetags/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/rest/templatetags/rest_filters.py b/rest/templatetags/rest_filters.py
new file mode 100644 (file)
index 0000000..bc68393
--- /dev/null
@@ -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