Move Order.add_record to save hook in abstract Product

This commit is contained in:
fnux 2020-03-09 17:25:02 +01:00
commit a7e9f3c09d
3 changed files with 14 additions and 31 deletions

View file

@ -127,11 +127,6 @@ class VMProductViewSet(ProductViewSet):
# Create VM.
vm = serializer.save(owner=request.user, order=order)
# Add Product record to order (VM is mutable, allows to keep history in order).
# XXX: Move this to some kind of on_create hook in parent Product class?
order.add_record(vm.one_time_price,
vm.recurring_price(order.recurring_period), vm.description)
return Response(serializer.data)
@ -215,9 +210,4 @@ class DCLCreateVMProductViewSet(ProductViewSet):
# Create VM.
vm = serializer.save(owner=request.user, order=order)
# Add Product record to order (VM is mutable, allows to keep history in order).
# XXX: Move this to some kind of on_create hook in parent Product class?
order.add_record(vm.one_time_price,
vm.recurring_price(order.recurring_period), vm.description)
return Response(serializer.data)