[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-bank] branch master updated: fix #5005
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-bank] branch master updated: fix #5005 |
Date: |
Tue, 09 May 2017 11:19:25 +0200 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository bank.
The following commit(s) were added to refs/heads/master by this push:
new f97a7eb fix #5005
f97a7eb is described below
commit f97a7eb332ccbb4f652aeb520b434cf56860c930
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue May 9 11:19:17 2017 +0200
fix #5005
---
talerbank/app/tests_admin.py | 3 ++-
talerbank/app/views.py | 24 ++++++++++++++++--------
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/talerbank/app/tests_admin.py b/talerbank/app/tests_admin.py
index 9023952..950fdc2 100644
--- a/talerbank/app/tests_admin.py
+++ b/talerbank/app/tests_admin.py
@@ -48,7 +48,7 @@ class AddIncomingTestCase(TestCase):
def test_add_incoming(self):
c = Client()
data = '{"auth": {"type": "basic"}, \
- "credit_account": 2, \
+ "credit_account": 1, \
"wtid": "TESTWTID", \
"exchange_url": "https://exchange.test", \
"amount": \
@@ -60,4 +60,5 @@ class AddIncomingTestCase(TestCase):
data=data,
content_type="application/json",
follow=True, **{"HTTP_X_TALER_BANK_USERNAME":
"user_user", "HTTP_X_TALER_BANK_PASSWORD": "user_password"})
+ logger.info(response.content.decode("utf-8"))
self.assertEqual(200, response.status_code)
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 7ed582f..d22bb4d 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -45,6 +45,8 @@ logger = logging.getLogger(__name__)
class DebtLimitExceededException(Exception):
pass
+class SameAccountException(Exception):
+ pass
class MyAuthenticationForm(django.contrib.auth.forms.AuthenticationForm):
def __init__(self, *args, **kwargs):
@@ -465,15 +467,16 @@ def add_incoming(request):
except BankAccount.DoesNotExist:
return HttpResponse(status=404)
try:
- wire_transfer(data["amount"],
- user_account.bankaccount,
- credit_account,
- subject)
+ transaction = wire_transfer(data["amount"],
+ user_account.bankaccount,
+ credit_account,
+ subject)
+ return JsonResponse(dict(row_id=transaction.id, timestamp="/Date(%s)/"
% int(transaction.date.timestamp())))
+ except SameAccountException:
+ return JsonResponse(dict(error="debit and credit account are the
same"), status=422)
except DebtLimitExceededException:
- return JsonResponse(dict(error="debit count has reached its debt
limit"),
+ return JsonResponse(dict(error="debit count has reached its debt
limit", status=403 ),
status=403)
- return HttpResponse(status=200)
-
@login_required
@require_POST
@@ -496,7 +499,9 @@ def wire_transfer(amount,
credit_account,
subject):
if debit_account.pk == credit_account.pk:
- return
+ logger.error("Debit and credit account are the same!")
+ raise SameAccountException()
+
transaction_item = BankTransaction(amount_value=amount["value"],
amount_fraction=amount["fraction"],
currency=amount["currency"],
@@ -530,6 +535,7 @@ def wire_transfer(amount,
# Check here if any account went beyond the allowed
# debit threshold.
+
threshold = amounts.parse_amount(settings.TALER_MAX_DEBT)
if debit_account.user.username == "Bank":
threshold = amounts.parse_amount(settings.TALER_MAX_DEBT_BANK)
@@ -545,3 +551,5 @@ def wire_transfer(amount,
debit_account.save()
credit_account.save()
transaction_item.save()
+
+ return transaction_item
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-bank] branch master updated: fix #5005,
gnunet <=