2017-12-22 17:02:24 +01:00
|
|
|
from django.contrib import admin
|
2019-12-27 18:28:30 +01:00
|
|
|
import nested_admin
|
|
|
|
|
2020-01-10 00:01:06 +01:00
|
|
|
from devices.models import DeviceInNet
|
2020-01-12 12:42:28 +01:00
|
|
|
from licenses.models import LicenseWithComputer
|
2020-01-10 00:01:06 +01:00
|
|
|
|
2020-01-01 21:24:49 +01:00
|
|
|
from .models import (
|
|
|
|
Computer,
|
|
|
|
ComputerCpuRelation,
|
|
|
|
ComputerDiskRelation,
|
2020-04-30 15:40:00 +02:00
|
|
|
ComputerGpuRelation,
|
2020-01-01 21:24:49 +01:00
|
|
|
ComputerRamRelation,
|
|
|
|
ComputerSoftwareRelation,
|
|
|
|
Cpu,
|
|
|
|
CpuArchitecture,
|
|
|
|
CpuManufacturer,
|
|
|
|
Disk,
|
|
|
|
DiskType,
|
|
|
|
DisksInRaid,
|
2020-04-30 15:40:00 +02:00
|
|
|
Gpu,
|
|
|
|
GpuManufacturer,
|
2020-01-01 21:24:49 +01:00
|
|
|
Raid,
|
|
|
|
RaidType,
|
|
|
|
Ram,
|
|
|
|
RamType,
|
|
|
|
)
|
2019-06-16 14:58:53 +02:00
|
|
|
|
|
|
|
|
2019-06-10 21:56:21 +02:00
|
|
|
class CpuAdmin(admin.ModelAdmin):
|
|
|
|
def get_model_perms(self, request):
|
|
|
|
"""
|
|
|
|
Return empty perms dict thus hiding the model from admin index.
|
|
|
|
"""
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
|
|
class CpuArchitectureAdmin(admin.ModelAdmin):
|
|
|
|
def get_model_perms(self, request):
|
|
|
|
"""
|
|
|
|
Return empty perms dict thus hiding the model from admin index.
|
|
|
|
"""
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
|
|
class CpuManufacturerAdmin(admin.ModelAdmin):
|
|
|
|
def get_model_perms(self, request):
|
|
|
|
"""
|
|
|
|
Return empty perms dict thus hiding the model from admin index.
|
|
|
|
"""
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
2020-04-30 15:40:00 +02:00
|
|
|
class GpuAdmin(admin.ModelAdmin):
|
|
|
|
def get_model_perms(self, request):
|
|
|
|
"""
|
|
|
|
Return empty perms dict thus hiding the model from admin index.
|
|
|
|
"""
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
|
|
class GpuManufacturerAdmin(admin.ModelAdmin):
|
|
|
|
def get_model_perms(self, request):
|
|
|
|
"""
|
|
|
|
Return empty perms dict thus hiding the model from admin index.
|
|
|
|
"""
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
2019-06-10 21:56:21 +02:00
|
|
|
class IpStatusAdmin(admin.ModelAdmin):
|
|
|
|
def get_model_perms(self, request):
|
|
|
|
"""
|
|
|
|
Return empty perms dict thus hiding the model from admin index.
|
|
|
|
"""
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
|
|
class RamModuleAdmin(admin.ModelAdmin):
|
|
|
|
def get_model_perms(self, request):
|
|
|
|
"""
|
|
|
|
Return empty perms dict thus hiding the model from admin index.
|
|
|
|
"""
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
|
|
class RaidTypeAdmin(admin.ModelAdmin):
|
|
|
|
def get_model_perms(self, request):
|
|
|
|
"""
|
|
|
|
Return empty perms dict thus hiding the model from admin index.
|
|
|
|
"""
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
|
|
class DiskTypeAdmin(admin.ModelAdmin):
|
|
|
|
def get_model_perms(self, request):
|
|
|
|
"""
|
|
|
|
Return empty perms dict thus hiding the model from admin index.
|
|
|
|
"""
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
|
|
class RamTypeAdmin(admin.ModelAdmin):
|
|
|
|
def get_model_perms(self, request):
|
|
|
|
"""
|
|
|
|
Return empty perms dict thus hiding the model from admin index.
|
|
|
|
"""
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
|
|
class DiskInRaidAdmin(admin.ModelAdmin):
|
|
|
|
def get_model_perms(self, request):
|
|
|
|
"""
|
|
|
|
Return empty perms dict thus hiding the model from admin index.
|
|
|
|
"""
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
2019-12-27 18:28:30 +01:00
|
|
|
class SoftwareInLine(nested_admin.NestedStackedInline):
|
2019-06-10 21:56:21 +02:00
|
|
|
model = ComputerSoftwareRelation
|
|
|
|
extra = 0
|
|
|
|
verbose_name_plural = 'Software'
|
2017-12-22 17:02:24 +01:00
|
|
|
|
|
|
|
|
2019-12-27 18:28:30 +01:00
|
|
|
class RamInLine(nested_admin.NestedStackedInline):
|
2017-12-22 17:02:24 +01:00
|
|
|
model = ComputerRamRelation
|
2017-12-24 23:57:30 +01:00
|
|
|
extra = 0
|
|
|
|
verbose_name_plural = 'RAM Modules'
|
2017-12-22 17:02:24 +01:00
|
|
|
|
|
|
|
|
2019-12-27 18:28:30 +01:00
|
|
|
class DiskInLine(nested_admin.NestedStackedInline):
|
2017-12-22 17:02:24 +01:00
|
|
|
model = ComputerDiskRelation
|
2017-12-24 23:57:30 +01:00
|
|
|
extra = 0
|
2017-12-22 17:02:24 +01:00
|
|
|
verbose_name_plural = 'Disks'
|
|
|
|
|
|
|
|
|
2019-12-27 18:28:30 +01:00
|
|
|
class DisksInRaidInLine(nested_admin.NestedStackedInline):
|
|
|
|
model = DisksInRaid
|
|
|
|
extra = 0
|
|
|
|
verbose_name_plural = 'Disks in RAID'
|
|
|
|
|
|
|
|
|
|
|
|
class CpusInLine(nested_admin.NestedStackedInline):
|
2017-12-24 23:57:30 +01:00
|
|
|
model = ComputerCpuRelation
|
|
|
|
extra = 0
|
|
|
|
verbose_name_plural = 'CPUs'
|
|
|
|
|
|
|
|
|
2020-04-30 15:40:00 +02:00
|
|
|
class GpusInLine(nested_admin.NestedStackedInline):
|
|
|
|
model = ComputerGpuRelation
|
|
|
|
extra = 0
|
|
|
|
verbose_name_plural = 'GPUs'
|
|
|
|
|
|
|
|
|
2019-12-27 18:28:30 +01:00
|
|
|
class RaidInLine(nested_admin.NestedStackedInline):
|
|
|
|
model = Raid
|
2019-06-10 21:56:21 +02:00
|
|
|
extra = 0
|
|
|
|
verbose_name_plural = 'RAID'
|
2019-12-27 18:28:30 +01:00
|
|
|
inlines = (DisksInRaidInLine,)
|
2017-12-22 17:02:24 +01:00
|
|
|
|
|
|
|
|
2019-12-27 18:28:30 +01:00
|
|
|
class DeviceInNetInline(nested_admin.NestedStackedInline):
|
2019-06-10 21:56:21 +02:00
|
|
|
model = DeviceInNet
|
|
|
|
extra = 0
|
|
|
|
verbose_name_plural = 'Nets'
|
|
|
|
|
|
|
|
|
2019-12-29 23:54:27 +01:00
|
|
|
class LicenseWithComputerInLine(nested_admin.NestedStackedInline):
|
|
|
|
model = LicenseWithComputer
|
|
|
|
extra = 0
|
|
|
|
verbose_name_plural = 'Licenses'
|
|
|
|
|
|
|
|
|
2019-12-27 18:28:30 +01:00
|
|
|
class ComputerAdmin(nested_admin.NestedModelAdmin):
|
2017-12-27 16:31:32 +01:00
|
|
|
list_display = ('name', 'host')
|
2020-04-30 15:40:00 +02:00
|
|
|
inlines = (SoftwareInLine, CpusInLine, GpusInLine, RamInLine, DiskInLine,
|
|
|
|
RaidInLine, DeviceInNetInline, LicenseWithComputerInLine)
|
2017-12-27 16:31:32 +01:00
|
|
|
|
|
|
|
|
2017-12-25 00:09:41 +01:00
|
|
|
admin.site.register(Computer, ComputerAdmin)
|
2019-06-10 21:56:21 +02:00
|
|
|
admin.site.register(Cpu, CpuAdmin)
|
|
|
|
admin.site.register(CpuArchitecture, CpuArchitectureAdmin)
|
|
|
|
admin.site.register(CpuManufacturer, CpuManufacturerAdmin)
|
|
|
|
admin.site.register(Disk)
|
|
|
|
admin.site.register(DiskType, DiskTypeAdmin)
|
2020-04-30 15:40:00 +02:00
|
|
|
admin.site.register(Gpu, GpuAdmin)
|
|
|
|
admin.site.register(GpuManufacturer, GpuManufacturerAdmin)
|
2019-06-10 21:56:21 +02:00
|
|
|
admin.site.register(RaidType, RaidTypeAdmin)
|
|
|
|
admin.site.register(Ram, RamModuleAdmin)
|
|
|
|
admin.site.register(RamType, RamTypeAdmin)
|