2017-12-22 17:02:24 +01:00
|
|
|
from django.shortcuts import get_object_or_404, render
|
2017-12-29 12:33:05 +01:00
|
|
|
from django.views.generic import ListView
|
2018-05-17 18:18:49 +02:00
|
|
|
from .models import (GeneralDevice, Computer, CronJob,
|
|
|
|
ComputerRamRelation,
|
|
|
|
ComputerDiskRelation,
|
|
|
|
ComputerCpuRelation)
|
2017-12-25 13:35:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
def device_details(request, device_id):
|
2017-12-25 16:23:42 +01:00
|
|
|
device = get_object_or_404(GeneralDevice, pk=device_id)
|
2017-12-25 13:35:09 +01:00
|
|
|
return render(request, 'inventory/device_details.html',
|
|
|
|
{'device': device})
|
|
|
|
|
|
|
|
|
2017-12-25 13:35:30 +01:00
|
|
|
def computer_details(request, computer_id):
|
|
|
|
computer = get_object_or_404(Computer, pk=computer_id)
|
2017-12-26 11:13:14 +01:00
|
|
|
disks_list = ComputerDiskRelation.objects.filter(computer=computer_id)
|
2017-12-25 13:35:30 +01:00
|
|
|
ram = ComputerRamRelation.objects.get(computer=computer_id)
|
|
|
|
cpu = ComputerCpuRelation.objects.get(computer=computer_id)
|
|
|
|
cronjob_list = CronJob.objects.filter(host=computer_id)
|
|
|
|
return render(request, 'inventory/computer_details.html',
|
|
|
|
{'computer': computer,
|
2017-12-26 11:13:14 +01:00
|
|
|
'disks_list': disks_list,
|
2017-12-25 13:35:30 +01:00
|
|
|
'ram': ram,
|
|
|
|
'cpu': cpu,
|
|
|
|
'cronjob_list': cronjob_list})
|
|
|
|
|
|
|
|
|
2017-12-25 13:36:03 +01:00
|
|
|
def cronjob_details(request, cronjob_id):
|
|
|
|
cronjob = get_object_or_404(CronJob, pk=cronjob_id)
|
|
|
|
return render(request, 'inventory/cronjob_details.html',
|
|
|
|
{'cronjob': cronjob})
|
2017-12-29 12:33:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
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'
|