diff --git a/uncloud_django_based/uncloud/uncloud_pay/models.py b/uncloud_django_based/uncloud/uncloud_pay/models.py index 9a8a49a..aca226e 100644 --- a/uncloud_django_based/uncloud/uncloud_pay/models.py +++ b/uncloud_django_based/uncloud/uncloud_pay/models.py @@ -845,15 +845,15 @@ class Order(models.Model): super().save(*args, **kwargs) - Bill.generate_for(self.starting_date.year, self.starting_date.month, self.owner) +# Bill.generate_for(self.starting_date.year, self.starting_date.month, self.owner) - # Used by uncloud_pay tests. - @property - def bills(self): - return Bill.objects.filter(order=self) + # # Used by uncloud_pay tests. + # @property + # def bills(self): + # return Bill.objects.filter(order=self) def __str__(self): - return "Order {} created at {}, {}->{}, recurring period {}. Price one time {}, recurring {}".format( + return "Order {} created at {}, {}->{}, recurring period {}. One time price {}, recurring price {}".format( self.uuid, self.creation_date, self.starting_date, self.ending_date, self.recurring_period, @@ -997,11 +997,10 @@ class Product(UncloudModel): raise ValidationError("Cannot order without a billing address") self.order = Order.objects.create(owner=self.owner, - billing_address=billing_address) + billing_address=billing_address, + one_time_price=self.one_time_price, + recurring_price=self.recurring_price) - - print("in save op: {}".format(self)) - print(self.order) super().save(*args, **kwargs) # # Make sure we only create records on creation. diff --git a/uncloud_django_based/uncloud/uncloud_vm/models.py b/uncloud_django_based/uncloud/uncloud_vm/models.py index 91c9291..a542503 100644 --- a/uncloud_django_based/uncloud/uncloud_vm/models.py +++ b/uncloud_django_based/uncloud/uncloud_vm/models.py @@ -69,7 +69,7 @@ class VMProduct(Product): cores = models.IntegerField() ram_in_gb = models.FloatField() - # Default recurring price is PER_MONTH, see uncloud_pay.models.Product. + @property def recurring_price(self): return self.cores * 3 + self.ram_in_gb * 4 @@ -79,6 +79,7 @@ class VMProduct(Product): self.name, self.cores, self.ram_in_gb) + @property def description(self): return "Virtual machine '{}': {} core(s), {}GB memory".format(