add list of lists

this lists show all the lists related to the currently selected customer.
This commit is contained in:
Andreas Zweili 2019-07-24 22:56:08 +02:00
parent abba395440
commit f8531e6014
3 changed files with 24 additions and 2 deletions

View File

@ -0,0 +1,15 @@
{% extends "inventory/base.html" %}
{% block section_title %}List of Lists{% endblock %}
{% block content %}
<table class="sortable">
<tr>
<th>Lists</th>
</tr>
<tr>
<td><a href="{% url 'computers' customer_id %}">Computers</a></td>
</tr>
<tr>
<td><a href="{% url 'devices' customer_id %}">Devices</a></td>
</tr>
</table>
{% endblock %}

View File

@ -9,7 +9,8 @@ urlpatterns = [
path('device/<int:device_id>/', views.device_details, name='device'),
path('computer/<int:computer_id>/', views.computer_details,
name='computer'),
path('devices/', views.DeviceList.as_view(), name='devices'),
path('devices/<int:customer_id>', views.DeviceList.as_view(),
name='devices'),
path('customer/<int:customer_id>/lists/', views.list_of_lists,
name='lists'),
]

View File

@ -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