1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# This file is part of TALER
# (C) 2014, 2015, 2106 INRIA
#
# TALER is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3, or (at your option) any later version.
#
# TALER is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
#
# @author Marcello Stanisci
from random import randint
from django.core.management.base import BaseCommand
from ...lib import get_public_accounts, wire_transfer_in_out
from django.conf import settings
from ...models import BankAccount
def sample_donations():
public_accounts = get_public_accounts()
for account in public_accounts:
for i in range(0, 9):
if account.user.username in settings.TALER_EXPECTS_DONATIONS:
value = randint(1, 100)
try:
# 1st take money from bank and give to exchange
wire_transfer_in_out({'value': value,
'fraction': 0,
'currency': settings.TALER_CURRENCY},
1,
2,
"Test withdrawal")
# 2nd take money from exchange and give to donation receiver
wire_transfer_in_out({'value': value,
'fraction': 0,
'currency': settings.TALER_CURRENCY},
2,
account.account_no,
"Test donation(s)")
except BankAccount.DoesNotExist:
print("Accounts not found. Run the 'provide_accounts' django management command")
return
except OperationalError:
print("No DB found, please create one beforehand. Try with taler-bank-manage createdb")
return
class Command(BaseCommand):
def handle(self, *args, **options):
sample_donations()
|