From 36ed48dfe56d215e80a892e236e0226d52251e5d Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand <benjamin.bertrand@esss.se> Date: Thu, 4 Jan 2018 11:57:33 +0100 Subject: [PATCH] Remove sorting on relationship columns Sorting on manufacturer/model/location/status requires a join which removes the row with empty field. Disable it until we find a way to sort properly including null values. --- app/inventory/views.py | 9 +-------- app/static/js/items.js | 4 ++++ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/inventory/views.py b/app/inventory/views.py index bcd6c00..e5e1058 100644 --- a/app/inventory/views.py +++ b/app/inventory/views.py @@ -73,14 +73,7 @@ def retrieve_items(): 'status', 'parent', ) - field = getattr(models.Item, columns[order_column]) - if 4 < order_column < 9: - query = query.join(field) - relationship_class = getattr(models, columns[order_column].title()) - relationship_field = getattr(relationship_class, 'name') - query = query.order_by(order_dir(relationship_field)) - else: - query = query.order_by(order_dir(getattr(models.Item, columns[order_column]))) + query = query.order_by(order_dir(getattr(models.Item, columns[order_column]))) # Limit and offset the query if per_page != -1: query = query.limit(per_page) diff --git a/app/static/js/items.js b/app/static/js/items.js index 75dbff6..364a509 100644 --- a/app/static/js/items.js +++ b/app/static/js/items.js @@ -64,6 +64,10 @@ $(document).ready(function() { "visible": false, "searchable": false }, + { + "targets": [5, 6, 7, 8], + "orderable": false + }, { "targets": [1, 9], "render": function(data, type, row) { -- GitLab