extend the documentation
This commit is contained in:
parent
26869813e0
commit
8b7eacaf8f
111
docs/docs.org
111
docs/docs.org
|
@ -448,22 +448,11 @@ the templates.
|
||||||
|
|
||||||
#+BEGIN_SRC python :tangle ../network_inventory/inventory/views.py
|
#+BEGIN_SRC python :tangle ../network_inventory/inventory/views.py
|
||||||
from django.shortcuts import get_object_or_404, render
|
from django.shortcuts import get_object_or_404, render
|
||||||
from .models import (GeneralDevice, Computer, CronJob,
|
from django.views.generic import ListView
|
||||||
ComputerRamRelation,
|
from inventory.models import (GeneralDevice, Computer, CronJob,
|
||||||
ComputerDiskRelation,
|
ComputerRamRelation,
|
||||||
ComputerCpuRelation)
|
ComputerDiskRelation,
|
||||||
|
ComputerCpuRelation)
|
||||||
|
|
||||||
def index(request):
|
|
||||||
device_list = GeneralDevice.objects.all()
|
|
||||||
computer_list = Computer.objects.all().order_by('ip')
|
|
||||||
cronjob_list = CronJob.objects.all().order_by('host')
|
|
||||||
|
|
||||||
return render(request,
|
|
||||||
'inventory/index.html',
|
|
||||||
{'device_list': device_list,
|
|
||||||
'computer_list': computer_list,
|
|
||||||
'cronjob_list': cronjob_list})
|
|
||||||
|
|
||||||
|
|
||||||
def device_details(request, device_id):
|
def device_details(request, device_id):
|
||||||
|
@ -490,6 +479,22 @@ def cronjob_details(request, cronjob_id):
|
||||||
cronjob = get_object_or_404(CronJob, pk=cronjob_id)
|
cronjob = get_object_or_404(CronJob, pk=cronjob_id)
|
||||||
return render(request, 'inventory/cronjob_details.html',
|
return render(request, 'inventory/cronjob_details.html',
|
||||||
{'cronjob': cronjob})
|
{'cronjob': cronjob})
|
||||||
|
|
||||||
|
|
||||||
|
class ComputerList(ListView):
|
||||||
|
model = Computer
|
||||||
|
template_name = 'inventory/computer_list.html'
|
||||||
|
|
||||||
|
|
||||||
|
class CronJobList(ListView):
|
||||||
|
model = CronJob
|
||||||
|
template_name = 'inventory/cronjob_list.html'
|
||||||
|
|
||||||
|
|
||||||
|
class DeviceList(ListView):
|
||||||
|
model = GeneralDevice
|
||||||
|
context_object_name = 'device_list'
|
||||||
|
template_name = 'inventory/device_list.html'
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
* URLs
|
* URLs
|
||||||
|
@ -537,10 +542,10 @@ from the root.
|
||||||
#+BEGIN_SRC python :tangle ../network_inventory/inventory/urls.py
|
#+BEGIN_SRC python :tangle ../network_inventory/inventory/urls.py
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
|
|
||||||
from . import views
|
from inventory import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', views.index, name='index'),
|
url(r'^$', views.ComputerList.as_view(), name='computers'),
|
||||||
url(r'^device/(?P<device_id>[0-9]+)/$',
|
url(r'^device/(?P<device_id>[0-9]+)/$',
|
||||||
views.device_details,
|
views.device_details,
|
||||||
name='device'),
|
name='device'),
|
||||||
|
@ -550,6 +555,8 @@ urlpatterns = [
|
||||||
url(r'^cronjob/(?P<cronjob_id>[0-9]+)/$',
|
url(r'^cronjob/(?P<cronjob_id>[0-9]+)/$',
|
||||||
views.cronjob_details,
|
views.cronjob_details,
|
||||||
name='cronjob'),
|
name='cronjob'),
|
||||||
|
url(r'^cronjobs/$', views.CronJobList.as_view(), name='cronjobs'),
|
||||||
|
url(r'^devices/$', views.DeviceList.as_view(), name='devices'),
|
||||||
]
|
]
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
@ -637,7 +644,9 @@ extended by them.
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<a href="{% url 'index' %}">Home</a>
|
<a href="{% url 'computers' %}">Computers</a> |
|
||||||
|
<a href="{% url 'devices' %}">Devices</a> |
|
||||||
|
<a href="{% url 'cronjobs' %}">Cron Jobs</a>
|
||||||
<h1>{% block section_title %}Device Inventory{% endblock %}</h1>
|
<h1>{% block section_title %}Device Inventory{% endblock %}</h1>
|
||||||
{% block content %}{% endblock %}
|
{% block content %}{% endblock %}
|
||||||
<footer>
|
<footer>
|
||||||
|
@ -645,29 +654,24 @@ extended by them.
|
||||||
<p class="copyright">Created by Andreas Zweili licensed under GPL v3.0</p>
|
<p class="copyright">Created by Andreas Zweili licensed under GPL v3.0</p>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</footer>
|
</footer>
|
||||||
|
<script src={% static 'inventory/js/sorttable.js' %}></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
** index.html
|
** computer_list.html
|
||||||
|
|
||||||
index.html is the landing page of the project. It gives a list
|
computer_list.html is the landing page of the project. It gives a list
|
||||||
overview over the active devices. In addition it shows some useful
|
overview over the active computers. In addition it shows some useful
|
||||||
information about the devices like IP addresses and similar
|
information about the devices like IP addresses and similar
|
||||||
information.
|
information.
|
||||||
|
|
||||||
#+BEGIN_SRC html :tangle ../network_inventory/inventory/templates/inventory/index.html
|
#+BEGIN_SRC html :tangle ../network_inventory/inventory/templates/inventory/computer_list.html
|
||||||
{% extends "inventory/base.html" %}
|
{% extends "inventory/base.html" %}
|
||||||
|
{% block section_title %}List of Computers{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if device_list or computer_list %}
|
{% if computer_list %}
|
||||||
<h3>Device List</h3>
|
<table class="sortable">
|
||||||
<ul>
|
|
||||||
{% for device in device_list %}
|
|
||||||
<li><a href="{% url 'device' device.id %}">{{ device.name }}</a></li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
<h3>Computer List</h3>
|
|
||||||
<table>
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>Hostname</th>
|
<th>Hostname</th>
|
||||||
<th>IP</th>
|
<th>IP</th>
|
||||||
|
@ -680,9 +684,40 @@ information.
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if cronjob_list %}
|
{% endblock %}
|
||||||
<h3>Cron Job List</h3>
|
#+END_SRC
|
||||||
<table>
|
|
||||||
|
** device_list.html
|
||||||
|
|
||||||
|
device_list.html provides an overview about all the general devices in
|
||||||
|
addition to a link to detail page of each device.
|
||||||
|
|
||||||
|
#+BEGIN_SRC html :tangle ../network_inventory/inventory/templates/inventory/device_list.html
|
||||||
|
{% extends "inventory/base.html" %}
|
||||||
|
{% block section_title %}List of General Devices{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
{% if device_list %}
|
||||||
|
<ul>
|
||||||
|
{% for device in device_list %}
|
||||||
|
<li><a href="{% url 'device' device.id %}">{{ device.name }}</a></li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** cronjob_list.html
|
||||||
|
|
||||||
|
cronjob_list.html provides an overview about all the cron jobs
|
||||||
|
including the time they are running and on which computer. In addtion
|
||||||
|
it provides a link to the detail page of each cron job.
|
||||||
|
|
||||||
|
#+BEGIN_SRC html :tangle ../network_inventory/inventory/templates/inventory/cronjob_list.html
|
||||||
|
{% extends "inventory/base.html" %}
|
||||||
|
{% block section_title %}List of Cron Jobs{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
{% if cronjob_list %}
|
||||||
|
<table class="sortable">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Hostname</th>
|
<th>Hostname</th>
|
||||||
|
@ -729,10 +764,10 @@ The computer details show all the known information about the selected computer.
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h3>Description</h3>
|
<h3>Description</h3>
|
||||||
<p>{{ computer.description }}</p>
|
<p>{{ computer.description }}</p>
|
||||||
<p><b>OS:</b> {{ computer.os }}</p>
|
<p><b>OS: </b>{{ computer.os }}</p>
|
||||||
<p><b>CPU:</b> {{ cpu.cpu }}</p>
|
<p><b>CPU: </b>{{ cpu.amount }}x {{ cpu.cpu }}</p>
|
||||||
<p><b>RAM Modules: </b>{{ ram.amount }}x {{ ram.ram }}</p>
|
<p><b>RAM Modules: </b>{{ ram.amount }}x {{ ram.ram }}</p>
|
||||||
<p><b>IP:</b> {{ computer.ip }}</p>
|
<p><b>IP: </b>{{ computer.ip }}</p>
|
||||||
{% if disks_list %}
|
{% if disks_list %}
|
||||||
<p><b>Disks:</b></p>
|
<p><b>Disks:</b></p>
|
||||||
<p>
|
<p>
|
||||||
|
|
Loading…
Reference in New Issue