[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-bank] branch master updated: add_bank_account: tolerate existing
From: |
gnunet |
Subject: |
[taler-bank] branch master updated: add_bank_account: tolerate existing accounts |
Date: |
Fri, 17 Jan 2020 22:39:55 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository bank.
The following commit(s) were added to refs/heads/master by this push:
new b415f76 add_bank_account: tolerate existing accounts
b415f76 is described below
commit b415f76ea7feb24d485f63c16502c686bbdb2331
Author: Florian Dold <address@hidden>
AuthorDate: Fri Jan 17 22:39:50 2020 +0100
add_bank_account: tolerate existing accounts
---
.../app/management/commands/add_bank_account.py | 25 +++++++++++++---------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/talerbank/app/management/commands/add_bank_account.py
b/talerbank/app/management/commands/add_bank_account.py
index 4c4aacf..b0e6513 100644
--- a/talerbank/app/management/commands/add_bank_account.py
+++ b/talerbank/app/management/commands/add_bank_account.py
@@ -35,7 +35,6 @@ import uuid
LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.INFO)
-
class Command(BaseCommand):
help = "Add bank accounts."
@@ -54,12 +53,18 @@ class Command(BaseCommand):
# for each one of them.
def handle(self, *args, **options):
accountname = options["accountname"]
- BankAccount(
- user=User.objects.create_user(
- username=accountname, password=str(uuid.uuid4())
- ),
- is_public=False,
- ).save()
- print(
- f"Created new bank account {accountname} (password set to random
password)"
- )
+ try:
+ existing_user = User.objects.get(username=accountname)
+ except User.DoesNotExist:
+ BankAccount(
+ user=User.objects.create_user(
+ username=accountname, password=str(uuid.uuid4())
+ ),
+ is_public=False,
+ ).save()
+ print(
+ f"Created new bank account {accountname} (password set to
random password)"
+ )
+ else:
+ print(f"Bank account {accountname} already exists.")
+
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-bank] branch master updated: add_bank_account: tolerate existing accounts,
gnunet <=