diff --git a/inventory/filters.py b/inventory/filters.py
new file mode 100644
index 0000000..dcf7b80
--- /dev/null
+++ b/inventory/filters.py
@@ -0,0 +1,7 @@
+import django_filters
+from inventory.models import Warehouse
+
+class WarehouseFilter(django_filters.FilterSet):
+ class Meta:
+ model = Warehouse
+ fields = ['name', 'address', 'have_freeze']
\ No newline at end of file
diff --git a/inventory/views.py b/inventory/views.py
index 3a72863..54d0185 100644
--- a/inventory/views.py
+++ b/inventory/views.py
@@ -1,6 +1,8 @@
from typing import Any
from django.shortcuts import render
from django.views.generic import TemplateView
+from django_filters.views import FilterView
+from inventory.filters import WarehouseFilter
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.auth.decorators import login_required
@@ -25,8 +27,10 @@ class OverviewView(TemplateView, LoginRequiredMixin):
return context
-class WarehouseView(TemplateView, LoginRequiredMixin):
+class WarehouseView(FilterView, LoginRequiredMixin):
+ model = Warehouse
template_name = "inventory/warehouse.html"
+ filterset_class = WarehouseFilter
def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
context = super().get_context_data(**kwargs)
diff --git a/templates/inventory/inventory.html b/templates/inventory/inventory.html
new file mode 100644
index 0000000..f361e4b
--- /dev/null
+++ b/templates/inventory/inventory.html
@@ -0,0 +1,89 @@
+{% extends "base.html" %}
+
+{% block content %}
+
+
+
+
+
+ {% include "nav.html" %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Warehouse Tables
+
Warehouse Table
+
+
+
+
+
+
+
+
+
+ | Name |
+ Address |
+ Stock Level |
+ Number of Inventory |
+ Have Freezer |
+
+
+
+
+ | Name |
+ Address |
+ Stock Level |
+ Number of Inventory |
+ Have Freezer |
+
+
+
+ {% for warehouse in warehouse_list %}
+
+ | {{ warehouse.name }} |
+ {{ warehouse.address }} |
+ {{ warehouse.stock_percentage|floatformat:3 }} |
+ {{ warehouse.inventory_count }} |
+ {{ warehouse.have_freeze }} |
+
+ {% endfor %}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {% include "footer.html" %}
+
+
+{% endblock content %}
\ No newline at end of file
diff --git a/templates/inventory/warehouse.html b/templates/inventory/warehouse.html
index bcfc2b1..f09f95f 100644
--- a/templates/inventory/warehouse.html
+++ b/templates/inventory/warehouse.html
@@ -22,6 +22,41 @@
Warehouse Tables
Warehouse Table
+
+
+
+
+
+
@@ -35,6 +70,7 @@
| Name |
Address |
+ Stock Level |
Number of Inventory |
Have Freezer |
@@ -43,19 +79,33 @@
| Name |
Address |
+ Stock Level |
Number of Inventory |
Have Freezer |
- {% for warehouse in warehouse_list %}
-
- | {{ warehouse.name }} |
- {{ warehouse.address }} |
- {{ warehouse.inventory_count }} |
- {{ warehouse.have_freeze }} |
-
- {% endfor %}
+ {% if filter.is_bound %}
+ {% for warehouse in filter.qs %}
+
+ | {{ warehouse.name }} |
+ {{ warehouse.address }} |
+ {{ warehouse.stock_percentage|floatformat:3 }} |
+ {{ warehouse.inventory_count }} |
+ {{ warehouse.have_freeze }} |
+
+ {% endfor %}
+ {% else %}
+ {% for warehouse in warehouse_list %}
+
+ | {{ warehouse.name }} |
+ {{ warehouse.address }} |
+ {{ warehouse.stock_percentage|floatformat:3 }} |
+ {{ warehouse.inventory_count }} |
+ {{ warehouse.have_freeze }} |
+
+ {% endfor %}
+ {% endif %}