forked from uncloud/uncloud
Fix a few errors on preview billing rework
Another WIP commit to sync with laptop, do not forget to rebase!
This commit is contained in:
parent
e319d1d151
commit
be2b0a8855
4 changed files with 25 additions and 8 deletions
|
|
@ -31,21 +31,15 @@ class VMProductViewSet(ProductViewSet):
|
|||
# Create base order.
|
||||
order = Order.objects.create(
|
||||
recurring_period=RecurringPeriod.PER_MONTH,
|
||||
recurring_price=0,
|
||||
one_time_price=0,
|
||||
owner=request.user
|
||||
)
|
||||
order.save()
|
||||
|
||||
# Create VM.
|
||||
serializer = VMProductSerializer(data=request.data, context={'request': request})
|
||||
serializer.is_valid(raise_exception=True)
|
||||
vm = serializer.save(owner=request.user, order=order)
|
||||
|
||||
# FIXME: commit everything (VM + order) at once.
|
||||
order.recurring_price = vm.recurring_price(order.recurring_period)
|
||||
order.one_time_price = 0
|
||||
order.save()
|
||||
|
||||
return Response(serializer.data)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue