From 06bfe426cfd4ee821b887ed915d28b3cbc4bcb5e Mon Sep 17 00:00:00 2001
From: Benjamin Bertrand <benjamin.bertrand@esss.se>
Date: Wed, 6 Sep 2017 09:53:46 +0200
Subject: [PATCH] Add parent to items table

---
 app/main/views.py            | 1 +
 app/static/js/inventory.js   | 2 +-
 app/templates/index.html     | 1 +
 tests/functional/test_web.py | 2 +-
 4 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/app/main/views.py b/app/main/views.py
index 9348ba4..479ba27 100644
--- a/app/main/views.py
+++ b/app/main/views.py
@@ -53,6 +53,7 @@ def retrieve_items():
              utils.format_field(item.model),
              utils.format_field(item.location),
              utils.format_field(item.status),
+             utils.format_field(item.parent),
              ] for item in items]
     return jsonify(data=data)
 
diff --git a/app/static/js/inventory.js b/app/static/js/inventory.js
index dbd50eb..68f95b9 100644
--- a/app/static/js/inventory.js
+++ b/app/static/js/inventory.js
@@ -19,7 +19,7 @@ $(document).ready(function() {
         "searchable": false
       },
       {
-        "targets": [1],
+        "targets": [1, 9],
         "render": function(data, type, row) {
           // render funtion to create link to Item view page
           if ( data === null ) {
diff --git a/app/templates/index.html b/app/templates/index.html
index 62cff4d..f76de15 100644
--- a/app/templates/index.html
+++ b/app/templates/index.html
@@ -16,6 +16,7 @@
         <th>Model</th>
         <th>Location</th>
         <th>Status</th>
+        <th>Parent</th>
       </tr>
     </thead>
   </table>
diff --git a/tests/functional/test_web.py b/tests/functional/test_web.py
index dfb119d..93ca521 100644
--- a/tests/functional/test_web.py
+++ b/tests/functional/test_web.py
@@ -82,4 +82,4 @@ def test_retrieve_items(logged_client, session):
     response = get(logged_client, '/_retrieve_items')
     items = response.json['data']
     assert set(serial_numbers) == set(item[4] for item in items)
-    assert len(items[0]) == 9
+    assert len(items[0]) == 10
-- 
GitLab