From 1d4243325856e9e866e6962f9e9aa48bc5278fb1 Mon Sep 17 00:00:00 2001 From: Yaro Kasear Date: Tue, 8 Jul 2025 15:53:56 -0500 Subject: [PATCH] Add inventory availability route and update inventory index layout - Introduced a new route for displaying available inventory items. - Sorted inventory items by identifier in both the list and available inventory routes. - Updated the inventory index template to include a link to the new available inventory route. - Cleaned up the layout by removing the toast container. --- inventory/routes/inventory.py | 18 +++++++++++++++++- inventory/templates/inventory_index.html | 8 ++++++++ inventory/templates/layout.html | 4 ---- 3 files changed, 25 insertions(+), 5 deletions(-) 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'}) }} +
+
+

Reports

+
+
+
+ {{ links.category_link(endpoint = 'inventory_available', label = 'Available', icon_html = icons.render_icon('box-seam', 32)) }} +
{% else %}
{% for line in listing %} diff --git a/inventory/templates/layout.html b/inventory/templates/layout.html index 0807f62..9c4ea7b 100644 --- a/inventory/templates/layout.html +++ b/inventory/templates/layout.html @@ -55,10 +55,6 @@
{% block content %}{% endblock %}
- - -
-