diff --git a/pinax/stripe/migrations/0001_initial.py b/pinax/stripe/migrations/0001_initial.py index af44be000..acd5d877c 100644 --- a/pinax/stripe/migrations/0001_initial.py +++ b/pinax/stripe/migrations/0001_initial.py @@ -104,7 +104,7 @@ class Migration(migrations.Migration): ('delinquent', models.BooleanField(default=False)), ('default_source', models.TextField(blank=True)), ('date_purged', models.DateTimeField(null=True, editable=False)), - ('user', models.OneToOneField(null=True, to=settings.AUTH_USER_MODEL)), + ('user', models.OneToOneField(null=True, to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), ], options={ 'abstract': False, @@ -125,7 +125,7 @@ class Migration(migrations.Migration): ('request', models.CharField(blank=True, max_length=100)), ('pending_webhooks', models.PositiveIntegerField(default=0)), ('api_version', models.CharField(blank=True, max_length=100)), - ('customer', models.ForeignKey(null=True, to='pinax_stripe.Customer')), + ('customer', models.ForeignKey(null=True, to='pinax_stripe.Customer', on_delete=models.CASCADE)), ], options={ 'abstract': False, @@ -139,7 +139,7 @@ class Migration(migrations.Migration): ('message', models.CharField(max_length=500)), ('traceback', models.TextField()), ('created_at', models.DateTimeField(default=django.utils.timezone.now)), - ('event', models.ForeignKey(null=True, to='pinax_stripe.Event')), + ('event', models.ForeignKey(null=True, to='pinax_stripe.Event', on_delete=models.CASCADE)), ], ), migrations.CreateModel( @@ -163,8 +163,8 @@ class Migration(migrations.Migration): ('total', models.DecimalField(decimal_places=2, max_digits=9)), ('date', models.DateTimeField()), ('webhooks_delivered_at', models.DateTimeField(null=True)), - ('charge', models.ForeignKey(null=True, related_name='invoices', to='pinax_stripe.Charge')), - ('customer', models.ForeignKey(related_name='invoices', to='pinax_stripe.Customer')), + ('charge', models.ForeignKey(null=True, related_name='invoices', to='pinax_stripe.Charge', on_delete=models.CASCADE)), + ('customer', models.ForeignKey(related_name='invoices', to='pinax_stripe.Customer', on_delete=models.CASCADE)), ], options={ 'abstract': False, @@ -185,7 +185,7 @@ class Migration(migrations.Migration): ('line_type', models.CharField(max_length=50)), ('description', models.CharField(blank=True, max_length=200)), ('quantity', models.IntegerField(null=True)), - ('invoice', models.ForeignKey(related_name='items', to='pinax_stripe.Invoice')), + ('invoice', models.ForeignKey(related_name='items', to='pinax_stripe.Invoice', on_delete=models.CASCADE)), ], ), migrations.CreateModel( @@ -223,8 +223,8 @@ class Migration(migrations.Migration): ('status', models.CharField(max_length=25)), ('trial_end', models.DateTimeField(null=True, blank=True)), ('trial_start', models.DateTimeField(null=True, blank=True)), - ('customer', models.ForeignKey(to='pinax_stripe.Customer')), - ('plan', models.ForeignKey(to='pinax_stripe.Plan')), + ('customer', models.ForeignKey(to='pinax_stripe.Customer', on_delete=models.CASCADE)), + ('plan', models.ForeignKey(to='pinax_stripe.Plan', on_delete=models.CASCADE)), ], options={ 'abstract': False, @@ -241,7 +241,7 @@ class Migration(migrations.Migration): ('status', models.CharField(max_length=25)), ('date', models.DateTimeField()), ('description', models.TextField(null=True, blank=True)), - ('event', models.ForeignKey(related_name='transfers', to='pinax_stripe.Event')), + ('event', models.ForeignKey(related_name='transfers', to='pinax_stripe.Event', on_delete=models.CASCADE)), ], options={ 'abstract': False, @@ -257,42 +257,42 @@ class Migration(migrations.Migration): ('description', models.TextField(null=True, blank=True)), ('kind', models.CharField(max_length=150)), ('created_at', models.DateTimeField(default=django.utils.timezone.now)), - ('transfer', models.ForeignKey(related_name='charge_fee_details', to='pinax_stripe.Transfer')), + ('transfer', models.ForeignKey(related_name='charge_fee_details', to='pinax_stripe.Transfer', on_delete=models.CASCADE)), ], ), migrations.AddField( model_name='invoiceitem', name='plan', - field=models.ForeignKey(null=True, to='pinax_stripe.Plan'), + field=models.ForeignKey(null=True, to='pinax_stripe.Plan', on_delete=models.CASCADE), ), migrations.AddField( model_name='invoiceitem', name='subscription', - field=models.ForeignKey(null=True, to='pinax_stripe.Subscription'), + field=models.ForeignKey(null=True, to='pinax_stripe.Subscription', on_delete=models.CASCADE), ), migrations.AddField( model_name='invoice', name='subscription', - field=models.ForeignKey(null=True, to='pinax_stripe.Subscription'), + field=models.ForeignKey(null=True, to='pinax_stripe.Subscription', on_delete=models.CASCADE), ), migrations.AddField( model_name='charge', name='customer', - field=models.ForeignKey(related_name='charges', to='pinax_stripe.Customer'), + field=models.ForeignKey(related_name='charges', to='pinax_stripe.Customer', on_delete=models.CASCADE), ), migrations.AddField( model_name='charge', name='invoice', - field=models.ForeignKey(null=True, related_name='charges', to='pinax_stripe.Invoice'), + field=models.ForeignKey(null=True, related_name='charges', to='pinax_stripe.Invoice', on_delete=models.CASCADE), ), migrations.AddField( model_name='card', name='customer', - field=models.ForeignKey(to='pinax_stripe.Customer'), + field=models.ForeignKey(to='pinax_stripe.Customer', on_delete=models.CASCADE), ), migrations.AddField( model_name='bitcoinreceiver', name='customer', - field=models.ForeignKey(to='pinax_stripe.Customer'), + field=models.ForeignKey(to='pinax_stripe.Customer', on_delete=models.CASCADE), ), ] diff --git a/pinax/stripe/models.py b/pinax/stripe/models.py index a210689ce..230df235c 100644 --- a/pinax/stripe/models.py +++ b/pinax/stripe/models.py @@ -66,7 +66,7 @@ def __str__(self): @python_2_unicode_compatible class EventProcessingException(models.Model): - event = models.ForeignKey("Event", null=True) + event = models.ForeignKey("Event", null=True, on_delete=models.CASCADE) data = models.TextField() message = models.CharField(max_length=500) traceback = models.TextField() @@ -81,7 +81,7 @@ class Event(StripeObject): kind = models.CharField(max_length=250) livemode = models.BooleanField(default=False) - customer = models.ForeignKey("Customer", null=True) + customer = models.ForeignKey("Customer", null=True, on_delete=models.CASCADE) webhook_message = JSONField() validated_message = JSONField(null=True) valid = models.NullBooleanField(null=True) @@ -99,7 +99,7 @@ def __str__(self): class Transfer(StripeObject): - event = models.ForeignKey(Event, related_name="transfers") + event = models.ForeignKey(Event, related_name="transfers", on_delete=models.CASCADE) amount = models.DecimalField(decimal_places=2, max_digits=9) currency = models.CharField(max_length=25, default="usd") status = models.CharField(max_length=25) @@ -109,7 +109,7 @@ class Transfer(StripeObject): class TransferChargeFee(models.Model): - transfer = models.ForeignKey(Transfer, related_name="charge_fee_details") + transfer = models.ForeignKey(Transfer, related_name="charge_fee_details", on_delete=models.CASCADE) amount = models.DecimalField(decimal_places=2, max_digits=9) currency = models.CharField(max_length=10, default="usd") application = models.TextField(null=True, blank=True) @@ -121,7 +121,7 @@ class TransferChargeFee(models.Model): @python_2_unicode_compatible class Customer(StripeObject): - user = models.OneToOneField(settings.AUTH_USER_MODEL, null=True) + user = models.OneToOneField(settings.AUTH_USER_MODEL, null=True, on_delete=models.CASCADE) account_balance = models.DecimalField(decimal_places=2, max_digits=9, null=True) currency = models.CharField(max_length=10, default="usd", blank=True) delinquent = models.BooleanField(default=False) @@ -140,7 +140,7 @@ def __str__(self): class Card(StripeObject): - customer = models.ForeignKey(Customer) + customer = models.ForeignKey(Customer, on_delete=models.CASCADE) name = models.TextField(blank=True) address_line_1 = models.TextField(blank=True) address_line_1_check = models.CharField(max_length=15) @@ -164,7 +164,7 @@ class Card(StripeObject): class BitcoinReceiver(StripeObject): - customer = models.ForeignKey(Customer) + customer = models.ForeignKey(Customer, on_delete=models.CASCADE) active = models.BooleanField(default=False) amount = models.DecimalField(decimal_places=2, max_digits=9) amount_received = models.DecimalField(decimal_places=2, max_digits=9, default=decimal.Decimal("0")) @@ -184,14 +184,14 @@ class BitcoinReceiver(StripeObject): class Subscription(StripeObject): - customer = models.ForeignKey(Customer) + customer = models.ForeignKey(Customer, on_delete=models.CASCADE) application_fee_percent = models.DecimalField(decimal_places=2, max_digits=3, default=None, null=True) cancel_at_period_end = models.BooleanField(default=False) canceled_at = models.DateTimeField(blank=True, null=True) current_period_end = models.DateTimeField(blank=True, null=True) current_period_start = models.DateTimeField(blank=True, null=True) ended_at = models.DateTimeField(blank=True, null=True) - plan = models.ForeignKey(Plan) + plan = models.ForeignKey(Plan, on_delete=models.CASCADE) quantity = models.IntegerField() start = models.DateTimeField() status = models.CharField(max_length=25) # trialing, active, past_due, canceled, or unpaid @@ -226,12 +226,12 @@ def delete(self, using=None): class Invoice(StripeObject): - customer = models.ForeignKey(Customer, related_name="invoices") + customer = models.ForeignKey(Customer, related_name="invoices", on_delete=models.CASCADE) amount_due = models.DecimalField(decimal_places=2, max_digits=9) attempted = models.NullBooleanField() attempt_count = models.PositiveIntegerField(null=True) - charge = models.ForeignKey("Charge", null=True, related_name="invoices") - subscription = models.ForeignKey(Subscription, null=True) + charge = models.ForeignKey("Charge", null=True, related_name="invoices", on_delete=models.CASCADE) + subscription = models.ForeignKey(Subscription, null=True, on_delete=models.CASCADE) statement_descriptor = models.TextField(blank=True) currency = models.CharField(max_length=10, default="usd") closed = models.BooleanField(default=False) @@ -258,18 +258,18 @@ class InvoiceItem(models.Model): stripe_id = models.CharField(max_length=255) created_at = models.DateTimeField(default=timezone.now) - invoice = models.ForeignKey(Invoice, related_name="items") + invoice = models.ForeignKey(Invoice, related_name="items", on_delete=models.CASCADE) amount = models.DecimalField(decimal_places=2, max_digits=9) currency = models.CharField(max_length=10, default="usd") quantity = models.PositiveIntegerField(null=True) kind = models.CharField(max_length=25, blank=True) - subscription = models.ForeignKey(Subscription, null=True) + subscription = models.ForeignKey(Subscription, null=True, on_delete=models.CASCADE) period_start = models.DateTimeField() period_end = models.DateTimeField() proration = models.BooleanField(default=False) line_type = models.CharField(max_length=50) description = models.CharField(max_length=200, blank=True) - plan = models.ForeignKey(Plan, null=True) + plan = models.ForeignKey(Plan, null=True, on_delete=models.CASCADE) quantity = models.IntegerField(null=True) def plan_display(self): @@ -278,8 +278,8 @@ def plan_display(self): class Charge(StripeObject): - customer = models.ForeignKey(Customer, related_name="charges") - invoice = models.ForeignKey(Invoice, null=True, related_name="charges") + customer = models.ForeignKey(Customer, related_name="charges", on_delete=models.CASCADE) + invoice = models.ForeignKey(Invoice, null=True, related_name="charges", on_delete=models.CASCADE) source = models.CharField(max_length=100) currency = models.CharField(max_length=10, default="usd") amount = models.DecimalField(decimal_places=2, max_digits=9, null=True)