add a customers details page

This commit is contained in:
Andreas Zweili 2019-07-25 20:34:52 +02:00
parent 9fec74496a
commit 368eb670e2
4 changed files with 16 additions and 3 deletions

View File

@ -17,6 +17,7 @@ class Owner(Company):
class Customer(Company):
name = models.CharField(max_length=50)
description = models.TextField()
def __str__(self):
return self.name

View File

@ -0,0 +1,6 @@
{% extends "inventory/base.html" %}
{% block section_title %}{{ customer.name }}{% endblock %}
{% block content %}
<h3>Description</h3>
<p>{{ customer.description }}</p>
{% endblock %}

View File

@ -4,7 +4,8 @@ from . import views
urlpatterns = [
path('', views.CustomerList.as_view(), name='customers'),
path('customer/<int:customer_id>/', views.ComputerList.as_view(),
path('customer/<int:pk>/', views.CustomerDetailView.as_view(),
name='customer'),
name='computers'),
path('device/<int:device_id>/', views.device_details, name='device'),
path('computer/<int:computer_id>/', views.computer_details,

View File

@ -1,6 +1,6 @@
from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404, render
from django.views.generic import ListView
from django.views.generic import ListView, DetailView
from guardian.shortcuts import get_objects_for_user
from .decorators import computer_view_permission
from .models import (Device, Computer, ComputerRamRelation,
@ -33,7 +33,12 @@ def list_of_lists(request, customer_id):
{'customer_id': customer_id})
class CustomerList(ListView):
class CustomerDetailView(DetailView):
model = Customer
template_name = 'inventory/customer_details.html'
class CustomerListView(ListView):
model = Customer
template_name = 'inventory/customer_list.html'