Also list snapshots for a VM
This commit is contained in:
parent
c6a9bd4363
commit
4b4cbbf009
3 changed files with 15 additions and 9 deletions
|
@ -8,8 +8,8 @@ from uncloud_pay.models import get_balance_for_user
|
|||
|
||||
class User(AbstractUser):
|
||||
"""
|
||||
We use the standard user and add a maximum negative credit that is allowed
|
||||
to be accumulated
|
||||
We use the standard user and add a maximum credit that is allowed
|
||||
to be accumulated. After that we need to have warnings, cancellation, etc.
|
||||
"""
|
||||
|
||||
maximum_credit = models.DecimalField(
|
||||
|
|
|
@ -186,4 +186,6 @@ class VMSnapshotProduct(Product):
|
|||
gb_ssd = models.FloatField(editable=False)
|
||||
gb_hdd = models.FloatField(editable=False)
|
||||
|
||||
vm = models.ForeignKey(VMProduct, on_delete=models.CASCADE)
|
||||
vm = models.ForeignKey(VMProduct,
|
||||
related_name='snapshots',
|
||||
on_delete=models.CASCADE)
|
||||
|
|
|
@ -32,15 +32,19 @@ class VMDiskImageProductSerializer(serializers.ModelSerializer):
|
|||
fields = '__all__'
|
||||
|
||||
class VMProductSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = VMProduct
|
||||
fields = ['uuid', 'order', 'owner', 'status', 'name',
|
||||
'cores', 'ram_in_gb', 'recurring_period',
|
||||
'snapshots' ]
|
||||
read_only_fields = ['uuid', 'order', 'owner', 'status']
|
||||
|
||||
# Custom field used at creation (= ordering) only.
|
||||
recurring_period = serializers.ChoiceField(
|
||||
choices=VMProduct.allowed_recurring_periods())
|
||||
|
||||
class Meta:
|
||||
model = VMProduct
|
||||
fields = ['uuid', 'order', 'owner', 'status', 'name', \
|
||||
'cores', 'ram_in_gb', 'recurring_period']
|
||||
read_only_fields = ['uuid', 'order', 'owner', 'status']
|
||||
snapshots = serializers.PrimaryKeyRelatedField(many=True,
|
||||
read_only=True)
|
||||
|
||||
|
||||
class DCLVMProductSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
|
Loading…
Reference in a new issue