implement a basic backup view
This commit is contained in:
parent
bb650d6d04
commit
268337cc5b
|
@ -1,5 +1,5 @@
|
|||
import django_tables2 as tables
|
||||
from .models import Net, Device
|
||||
from .models import Net, Device, Backup
|
||||
from django_tables2.utils import A
|
||||
|
||||
class CustomersTable(tables.Table):
|
||||
|
@ -47,3 +47,9 @@ class NetDetailTable(tables.Table):
|
|||
class Meta:
|
||||
template_name = 'django_tables2/semantic.html'
|
||||
model = Net
|
||||
|
||||
|
||||
class BackupDetailTable(tables.Table):
|
||||
class Meta:
|
||||
template_name = 'django_tables2/semantic.html'
|
||||
model = Backup
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{% extends "inventory/base.html" %}
|
||||
{% load render_table from django_tables2 %}
|
||||
{% block section_title %}{{ net.name }}{% endblock %}
|
||||
{% block content %}
|
||||
{% render_table backup %}
|
||||
{% endblock %}
|
|
@ -54,15 +54,25 @@
|
|||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% if software_list %}
|
||||
{% if software_list or backup_list %}
|
||||
<div class="card">
|
||||
<div class="content">
|
||||
{% if software_list %}
|
||||
<div class="header">Software</div>
|
||||
<ul>
|
||||
{% for software in software_list %}
|
||||
<li>{{ software.software }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% if backup_list %}
|
||||
<div class="header">Backup</div>
|
||||
<ul>
|
||||
{% for backup in backup_list %}
|
||||
<li><a href="{% url 'backup' backup.id %}">{{ backup }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
|
@ -16,4 +16,5 @@ urlpatterns = [
|
|||
path('customer/<int:customer_id>/nets/', views.nets_table_view,
|
||||
name='nets'),
|
||||
path('net/<int:pk>/', views.net_detail_view, name='net'),
|
||||
path('backup/<int:pk>/', views.backup_detail_view, name='backup'),
|
||||
]
|
||||
|
|
|
@ -6,8 +6,9 @@ from django_tables2 import RequestConfig
|
|||
from .decorators import computer_view_permission
|
||||
from .models import (Device, Computer, ComputerRamRelation,
|
||||
ComputerDiskRelation, ComputerCpuRelation,
|
||||
ComputerSoftwareRelation, Customer, Net, RaidInComputer)
|
||||
from .tables import CustomersTable, ComputersTable, DevicesTable, NetsTable, NetDetailTable
|
||||
ComputerSoftwareRelation, Customer, Net, RaidInComputer,
|
||||
Backup)
|
||||
from .tables import CustomersTable, ComputersTable, DevicesTable, NetsTable, NetDetailTable, BackupDetailTable
|
||||
|
||||
|
||||
def device_detail_view(request, device_id):
|
||||
|
@ -25,12 +26,15 @@ def computer_detail_view(request, computer_id):
|
|||
cpu_list = ComputerCpuRelation.objects.filter(computer=computer_id)
|
||||
software_list = ComputerSoftwareRelation.objects.filter(computer=computer_id)
|
||||
raid_relations = RaidInComputer.objects.filter(computer=computer_id)
|
||||
raid_relations = RaidInComputer.objects.filter(computer=computer_id)
|
||||
backup_list = Backup.objects.filter(computer=computer_id)
|
||||
context = {'computer': computer,
|
||||
'disks_list': disks_list,
|
||||
'ram_list': ram_list,
|
||||
'cpu_list': cpu_list,
|
||||
'software_list': software_list,
|
||||
'raid_relations': raid_relations}
|
||||
'raid_relations': raid_relations,
|
||||
'backup_list': backup_list }
|
||||
return render(request, 'inventory/computer_details.html', context)
|
||||
|
||||
|
||||
|
@ -70,3 +74,9 @@ def net_detail_view(request, pk):
|
|||
table = NetDetailTable(Net.objects.filter(pk=pk))
|
||||
RequestConfig(request).configure(table)
|
||||
return render(request, 'inventory/net_details.html', {'net': table})
|
||||
|
||||
|
||||
def backup_detail_view(request, pk):
|
||||
table = BackupDetailTable(Backup.objects.filter(pk=pk))
|
||||
RequestConfig(request).configure(table)
|
||||
return render(request, 'inventory/backup_details.html', {'backup': table})
|
||||
|
|
Loading…
Reference in New Issue