diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-04-11 17:57:05 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-04-11 17:57:05 +0200 |
commit | 2327735ebef6810c7d14371e611973e432ca75dc (patch) | |
tree | 04504941712c397882f1bdfb36a78770c475c2ed /talerbank/app/migrations/0001_initial.py | |
parent | efe77fd293f2b517d1aa623b4d1ffa884e10739d (diff) | |
download | bank-2327735ebef6810c7d14371e611973e432ca75dc.tar.gz bank-2327735ebef6810c7d14371e611973e432ca75dc.tar.bz2 bank-2327735ebef6810c7d14371e611973e432ca75dc.zip |
Better error handling, create required accounts in migrations
Diffstat (limited to 'talerbank/app/migrations/0001_initial.py')
-rw-r--r-- | talerbank/app/migrations/0001_initial.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/talerbank/app/migrations/0001_initial.py b/talerbank/app/migrations/0001_initial.py index d92797c..a98a244 100644 --- a/talerbank/app/migrations/0001_initial.py +++ b/talerbank/app/migrations/0001_initial.py @@ -1,10 +1,27 @@ # -*- coding: utf-8 -*- # Generated by Django 1.9.4 on 2016-04-08 14:17 from __future__ import unicode_literals - +import logging from django.conf import settings from django.db import migrations, models import django.db.models.deletion +from django.contrib.auth.models import User +from .models import BankAccount + + +def basic_accounts(apps, schema_editor): + bank = User.objects.create_user(username='Bank', password='') + exchange = User.objects.create_user(username='Exchange', password='') + bank_ba = BankAccount(user=bank, + currency=get_currency(None), + is_public=True) + bank_ba.save() + logging.info("Creating '" + bank_ba.user.username + "' account, with number " + str(bank_ba.account_no) + "\n") + exchange_ba = BankAccount(user=exchange, + currency=get_currency(None), + is_public=True) + exchange_ba.save() + logging.info("Creating '" + exchange_ba.user.username + "' account, with number " + str(exchange_ba.account_no) + "\n") class Migration(migrations.Migration): @@ -39,4 +56,5 @@ class Migration(migrations.Migration): ('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.BankAccount')), ], ), + migrations.RunPython(basic_accounts), ] |