From c9a941e29073fbdcd297f5b989073b0d01235df4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 1 Aug 2020 18:48:51 +0200 Subject: [PATCH] [vm] add disks inlined to VMs --- uncloud_vm/admin.py | 10 +++++++++- uncloud_vm/models.py | 7 ++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/uncloud_vm/admin.py b/uncloud_vm/admin.py index 9fbcb82..9f30b04 100644 --- a/uncloud_vm/admin.py +++ b/uncloud_vm/admin.py @@ -3,5 +3,13 @@ from django.contrib import admin # Register your models here. from uncloud_vm.models import * -admin.site.register(VMProduct) +class VMDiskInline(admin.TabularInline): + model = VMDiskProduct + +class VMProductAdmin(admin.ModelAdmin): + inlines = [ + VMDiskInline, + ] + +admin.site.register(VMProduct, VMProductAdmin) admin.site.register(VMDiskProduct) diff --git a/uncloud_vm/models.py b/uncloud_vm/models.py index 89ee431..8d9b35f 100644 --- a/uncloud_vm/models.py +++ b/uncloud_vm/models.py @@ -163,9 +163,10 @@ class VMDiskProduct(Product): choices=VMDiskType.choices, default=VMDiskType.CEPH_SSD) - @property - def description(self): - return "Disk for VM '{}': {}GB".format(self.vm.name, self.size_in_gb) + def __str__(self): + return "{} disk for VM '{}': {}GB".format(self.disk_type, + self.vm.name, + self.size_in_gb) @property def recurring_price(self):