2020-06-21 14:08:00 +00:00
|
|
|
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):
|
2020-08-01 12:05:36 +00:00
|
|
|
parser.add_argument('--username', type=str, required=True)
|
2020-06-21 14:08:00 +00:00
|
|
|
|
|
|
|
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)
|
2020-08-01 12:05:36 +00:00
|
|
|
|
2020-06-21 14:08:00 +00:00
|
|
|
print(f"Addr: {addr}")
|
|
|
|
print(f"Bill: {bill}")
|