From f8531e6014fe21d58271800f4f328147064b88d3 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Wed, 24 Jul 2019 22:56:08 +0200 Subject: [PATCH] add list of lists this lists show all the lists related to the currently selected customer. --- .../templates/inventory/list_of_lists.html | 15 +++++++++++++++ network_inventory/inventory/urls.py | 3 ++- network_inventory/inventory/views.py | 8 +++++++- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 network_inventory/inventory/templates/inventory/list_of_lists.html diff --git a/network_inventory/inventory/templates/inventory/list_of_lists.html b/network_inventory/inventory/templates/inventory/list_of_lists.html new file mode 100644 index 0000000..ff2c574 --- /dev/null +++ b/network_inventory/inventory/templates/inventory/list_of_lists.html @@ -0,0 +1,15 @@ +{% extends "inventory/base.html" %} +{% block section_title %}List of Lists{% endblock %} +{% block content %} + + + + + + + + + + +
Lists
Computers
Devices
+{% endblock %} diff --git a/network_inventory/inventory/urls.py b/network_inventory/inventory/urls.py index 5a3d11e..efde4dd 100644 --- a/network_inventory/inventory/urls.py +++ b/network_inventory/inventory/urls.py @@ -9,7 +9,8 @@ urlpatterns = [ path('device//', views.device_details, name='device'), path('computer//', views.computer_details, name='computer'), - path('devices/', views.DeviceList.as_view(), name='devices'), + path('devices/', views.DeviceList.as_view(), + name='devices'), path('customer//lists/', views.list_of_lists, name='lists'), ] diff --git a/network_inventory/inventory/views.py b/network_inventory/inventory/views.py index dcfb73d..5925a35 100644 --- a/network_inventory/inventory/views.py +++ b/network_inventory/inventory/views.py @@ -29,7 +29,8 @@ def computer_details(request, computer_id): def list_of_lists(request, customer_id): - return render(request, 'inventory/list_of_lists.html') + return render(request, 'inventory/list_of_lists.html', + {'customer_id': customer_id}) class CustomerList(ListView): @@ -56,3 +57,8 @@ class DeviceList(ListView): model = Device context_object_name = 'device_list' template_name = 'inventory/device_list.html' + + def get_queryset(self): + queryset = Device.objects.filter(customer=self.kwargs['customer_id']) + return queryset +