Skip to content

Commit

Permalink
Fix non-blank nullable Charge fields
Browse files Browse the repository at this point in the history
  • Loading branch information
jleclanche committed Nov 29, 2020
1 parent 5cff324 commit 894197b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
5 changes: 4 additions & 1 deletion djstripe/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,9 @@ class Migration(migrations.Migration):
(
"shipping",
djstripe.fields.JSONField(
help_text="Shipping information for the charge", null=True
help_text="Shipping information for the charge",
null=True,
blank=True,
),
),
(
Expand Down Expand Up @@ -2769,6 +2771,7 @@ class Migration(migrations.Migration):
field=djstripe.fields.PaymentMethodForeignKey(
help_text="The source used for this charge.",
null=True,
blank=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="charges",
to="djstripe.paymentmethod",
Expand Down
2 changes: 2 additions & 0 deletions djstripe/migrations/0007_2_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,7 @@ class Migration(migrations.Migration):
field=djstripe.fields.StripeForeignKey(
help_text="The transfer which created this charge. Only present if the charge came from another Stripe account.",
null=True,
blank=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="djstripe.transfer",
Expand Down Expand Up @@ -1133,6 +1134,7 @@ class Migration(migrations.Migration):
field=djstripe.fields.StripeForeignKey(
help_text="The transfer to the `destination` account (only applicable if the charge was created using the `destination` parameter).",
null=True,
blank=True,
on_delete=django.db.models.deletion.CASCADE,
to="djstripe.transfer",
to_field=settings.DJSTRIPE_FOREIGN_KEY_TO_FIELD,
Expand Down
15 changes: 11 additions & 4 deletions djstripe/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,20 @@ class Charge(StripeModel):
"this attribute will still be false.",
)
# TODO: review (requires Review model)
shipping = JSONField(null=True, help_text="Shipping information for the charge")
shipping = JSONField(
null=True, blank=True, help_text="Shipping information for the charge"
)
source = PaymentMethodForeignKey(
on_delete=models.SET_NULL,
null=True,
blank=True,
related_name="charges",
help_text="The source used for this charge.",
)
source_transfer = StripeForeignKey(
"Transfer",
null=True,
blank=True,
on_delete=models.CASCADE,
help_text="The transfer which created this charge. Only present if the "
"charge came from another Stripe account.",
Expand Down Expand Up @@ -307,10 +311,13 @@ class Charge(StripeModel):
)
transfer = StripeForeignKey(
"Transfer",
null=True,
on_delete=models.CASCADE,
help_text="The transfer to the `destination` account (only applicable "
"if the charge was created using the `destination` parameter).",
null=True,
blank=True,
help_text=(
"The transfer to the `destination` account (only applicable if "
"the charge was created using the `destination` parameter)."
),
)
transfer_data = JSONField(
null=True,
Expand Down
1 change: 1 addition & 0 deletions docs/history/2_4_x.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
matching that of the `Plan` model. However, Price amounts are already in cent. The
property has been removed, use `unit_amount` instead.
- Fix `Price.human_readable_price` calculation
- Fix non-blank nullable `Charge` fields

0 comments on commit 894197b

Please sign in to comment.