From 181005ad6c232b355ae01b62c29a53e3db00b6f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Floure?= Date: Fri, 28 Feb 2020 15:07:20 +0100 Subject: [PATCH] Cleanup VMProduct serializer, add name field to VMProduct --- uncloud/uncloud_vm/models.py | 4 ++++ uncloud/uncloud_vm/serializers.py | 8 +++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/uncloud/uncloud_vm/models.py b/uncloud/uncloud_vm/models.py index 663765a..be1178e 100644 --- a/uncloud/uncloud_vm/models.py +++ b/uncloud/uncloud_vm/models.py @@ -41,6 +41,10 @@ class VMProduct(Product): null=True) description = "Virtual Machine" + + # VM-specific. The name is only intended for customers: it's a pain te + # remember IDs (speaking from experience as ungleich customer)! + name = models.CharField(max_length=32) cores = models.IntegerField() ram_in_gb = models.FloatField() diff --git a/uncloud/uncloud_vm/serializers.py b/uncloud/uncloud_vm/serializers.py index b247709..cb60cfe 100644 --- a/uncloud/uncloud_vm/serializers.py +++ b/uncloud/uncloud_vm/serializers.py @@ -12,11 +12,9 @@ class VMHostSerializer(serializers.HyperlinkedModelSerializer): class VMProductSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = VMProduct - fields = '__all__' - - -# def create(self, validated_data): -# return VMSnapshotProduct() + fields = ['uuid', 'description', 'order', 'owner', 'status', 'name', \ + 'cores', 'ram_in_gb'] + read_only_fields = ['uuid', 'description', 'order', 'owner', 'status'] class VMSnapshotProductSerializer(serializers.ModelSerializer): class Meta: