Skip to content

Commit

Permalink
Merge pull request #288 from felixxm/issue-255
Browse files Browse the repository at this point in the history
Fixed #255 -- on_delete will be a required arg for ForeignKey/OneToOneField in Django 2.0.
  • Loading branch information
paltman authored Dec 21, 2016
2 parents 08859b2 + 94b93fd commit ec14b69
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
34 changes: 17 additions & 17 deletions pinax/stripe/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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(
Expand All @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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),
),
]
34 changes: 17 additions & 17 deletions pinax/stripe/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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"))
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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):
Expand All @@ -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)
Expand Down

0 comments on commit ec14b69

Please sign in to comment.