Include BillRecords in the admin

This commit is contained in:
Nico Schottelius 2020-06-21 16:08:00 +02:00
commit 8a17ee6de5
4 changed files with 128 additions and 21 deletions

View file

@ -0,0 +1,40 @@
from django.core.management.base import BaseCommand
from django.contrib.auth import get_user_model
import datetime
from uncloud_pay.models import *
class Command(BaseCommand):
help = 'Bootstrap user (for testing)'
def add_arguments(self, parser):
parser.add_argument('username', type=str)
def handle(self, *args, **options):
user = get_user_model().objects.get(username=options['username'])
addr = BillingAddress.objects.get_or_create(
owner=user,
active=True,
defaults={'organization': 'ungleich',
'name': 'Nico Schottelius',
'street': 'Hauptstrasse 14',
'city': 'Luchsingen',
'postal_code': '8775',
'country': 'CH' }
)
bills = Bill.objects.filter(owner=user)
# not even one bill? create!
if bills:
bill = bills[0]
else:
bill = Bill.objects.create(owner=user)
# find any order that is associated to this bill
orders = Order.objects.filter(owner=user)
)
print(f"Addr: {addr}")
print(f"Bill: {bill}")