From 38d074811a12c73d5cc1390422adf75a9b960570 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 20 Apr 2019 12:41:30 +0200 Subject: [PATCH] Link HostingBillLineItem to StripePlan --- .../0053_hostingbilllineitem_stripe_plan.py | 22 +++++++++++++++++++ hosting/models.py | 7 ++++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 hosting/migrations/0053_hostingbilllineitem_stripe_plan.py diff --git a/hosting/migrations/0053_hostingbilllineitem_stripe_plan.py b/hosting/migrations/0053_hostingbilllineitem_stripe_plan.py new file mode 100644 index 00000000..21580447 --- /dev/null +++ b/hosting/migrations/0053_hostingbilllineitem_stripe_plan.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2019-04-20 10:10 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('datacenterlight', '0028_stripeplan_stripe_plan_name'), + ('hosting', '0052_hostingbilllineitem'), + ] + + operations = [ + migrations.AddField( + model_name='hostingbilllineitem', + name='stripe_plan', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='datacenterlight.StripePlan'), + ), + ] diff --git a/hosting/models.py b/hosting/models.py index a113b80a..8ef36ffb 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -10,7 +10,7 @@ from django.db import models from django.utils import timezone from django.utils.functional import cached_property -from datacenterlight.models import VMPricing, VMTemplate +from datacenterlight.models import VMPricing, VMTemplate, StripePlan from membership.models import StripeCustomer, CustomUser from utils.mixins import AssignPermissionsMixin from utils.models import BillingAddress @@ -431,7 +431,10 @@ class HostingBillLineItem(AssignPermissionsMixin, models.Model): """ Corresponds to InvoiceItem object of Stripe """ - monthly_hosting_bill = models.ForeignKey(MonthlyHostingBill) + monthly_hosting_bill = models.ForeignKey(MonthlyHostingBill, + on_delete=models.CASCADE) + stripe_plan = models.ForeignKey(StripePlan, null=True, + on_delete=models.CASCADE) amount = models.PositiveSmallIntegerField() description = models.CharField(max_length=255) discountable = models.BooleanField()