diff --git a/inventory/routes/inventory.py b/inventory/routes/inventory.py index effc285..1b885a4 100644 --- a/inventory/routes/inventory.py +++ b/inventory/routes/inventory.py @@ -17,7 +17,7 @@ def list_inventory(): query = db.session.query(Inventory) query = eager_load_inventory_relationships(query) - query = query.order_by(Inventory.inventory_name, Inventory.barcode, Inventory.serial) + # query = query.order_by(Inventory.inventory_name, Inventory.barcode, Inventory.serial) if filter_by and id: column = FILTER_MAP.get(filter_by) @@ -41,6 +41,7 @@ def list_inventory(): return "Invalid filter_by parameter", 400 inventory = query.all() + inventory = sorted(inventory, key=lambda i: i.identifier) return render_template( 'table.html', @@ -205,3 +206,18 @@ def delete_inventory_item(id): db.session.rollback() return jsonify({"success": False, "error": str(e)}), 400 +@main.route("/inventory_available") +def inventory_available(): + query = eager_load_inventory_relationships(db.session.query(Inventory).filter(Inventory.condition == "Working")) + + inventory = query.all() + inventory = sorted(inventory, key=lambda i: i.identifier) + + return render_template( + "table.html", + title = "Available Inventory", + breadcrumb = [{'label': 'Inventory', 'url': url_for('main.inventory_index')}], + header=inventory_headers, + rows=[{"id": item.id, "cells": [row_fn(item) for row_fn in inventory_headers.values()]} for item in inventory], + entry_route = 'inventory_item' + ) \ No newline at end of file diff --git a/inventory/templates/inventory_index.html b/inventory/templates/inventory_index.html index 6e40621..2bb4d25 100644 --- a/inventory/templates/inventory_index.html +++ b/inventory/templates/inventory_index.html @@ -21,6 +21,14 @@ title=title {{ links.category_link(endpoint = 'inventory_index', label = 'By Location', icon_html = icons.render_icon('map', 32), arguments = {'category': 'location'}) }} {{ links.category_link(endpoint = 'inventory_index', label = 'By Type', icon_html = icons.render_icon('motherboard', 32), arguments = {'category': 'type'}) }} +