Make HostingOrder not mandatory in MonthlyHostingBill
This commit is contained in:
parent
c081f9e73a
commit
eb360c7406
2 changed files with 34 additions and 4 deletions
21
hosting/migrations/0053_auto_20190415_1952.py
Normal file
21
hosting/migrations/0053_auto_20190415_1952.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.9.4 on 2019-04-15 19:52
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('hosting', '0052_hostingbilllineitem'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='monthlyhostingbill',
|
||||||
|
name='order',
|
||||||
|
field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, to='hosting.HostingOrder'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -240,7 +240,10 @@ class MonthlyHostingBill(AssignPermissionsMixin, models.Model):
|
||||||
Corresponds to Invoice object of Stripe
|
Corresponds to Invoice object of Stripe
|
||||||
"""
|
"""
|
||||||
customer = models.ForeignKey(StripeCustomer)
|
customer = models.ForeignKey(StripeCustomer)
|
||||||
order = models.ForeignKey(HostingOrder)
|
order = models.ForeignKey(
|
||||||
|
HostingOrder, null=True, blank=True, default=None,
|
||||||
|
on_delete=models.SET_NULL
|
||||||
|
)
|
||||||
created = models.DateTimeField(help_text="When the invoice was created")
|
created = models.DateTimeField(help_text="When the invoice was created")
|
||||||
receipt_number = models.CharField(
|
receipt_number = models.CharField(
|
||||||
help_text="The receipt number that is generated on Stripe",
|
help_text="The receipt number that is generated on Stripe",
|
||||||
|
@ -274,9 +277,15 @@ class MonthlyHostingBill(AssignPermissionsMixin, models.Model):
|
||||||
if len(args['subscription_ids_csv']) > 0:
|
if len(args['subscription_ids_csv']) > 0:
|
||||||
sub_ids = [sub_id.strip() for sub_id in args['subscription_ids_csv'].split(",")]
|
sub_ids = [sub_id.strip() for sub_id in args['subscription_ids_csv'].split(",")]
|
||||||
if len(sub_ids) == 1:
|
if len(sub_ids) == 1:
|
||||||
args['order'] = HostingOrder.objects.get(
|
try:
|
||||||
subscription_id=sub_ids[0]
|
args['order'] = HostingOrder.objects.get(
|
||||||
)
|
subscription_id=sub_ids[0]
|
||||||
|
)
|
||||||
|
except HostingOrder.DoesNotExist as dne:
|
||||||
|
logger.error("Hosting order for {} doesn't exist".format(
|
||||||
|
sub_ids[0]
|
||||||
|
))
|
||||||
|
args['order'] = None
|
||||||
else:
|
else:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"More than one subscriptions"
|
"More than one subscriptions"
|
||||||
|
|
Loading…
Add table
Reference in a new issue