gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-bank] branch master updated: extract and json-format


From: gnunet
Subject: [GNUnet-SVN] [taler-bank] branch master updated: extract and json-format /history outcome
Date: Thu, 30 Mar 2017 17:56:40 +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 0838e22  extract and json-format /history outcome
0838e22 is described below

commit 0838e22604a31f65a430d9e6fb68ca2fb9c490e8
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Mar 30 17:56:31 2017 +0200

    extract and json-format /history outcome
---
 talerbank/app/tests.py |  4 +++-
 talerbank/app/views.py | 23 +++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/talerbank/app/tests.py b/talerbank/app/tests.py
index ac8c268..6170025 100644
--- a/talerbank/app/tests.py
+++ b/talerbank/app/tests.py
@@ -103,7 +103,9 @@ class HistoryTestCase(TestCase):
         c = Client()
         response = c.post(reverse("history", urlconf=urls),
                           data= '{"username": "User", \
-                                  "password": "Passoword"}',
+                                  "password": "Passoword", \
+                                  "start": 4, \
+                                  "delta": 4}',
                           content_type="application/json")
         self.assertEqual(200, response.status_code)
 
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index bd544ee..efdbd4d 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -352,7 +352,30 @@ def history(request):
                              "hint": "authentication failed"},
                              status=401)
 
+    start = data.get("start", 0)
+    delta = data.get("delta", 0)
+    
+    qs = 
BankTransaction.objects.filter((Q(debit_account=user_account.bankaccount) |
+                                         
Q(credit_account=user_account.bankaccount)) &
+                                         Q(id__gt=0))[:delta]
+
+    logger.info("Found %d results for user '%s'" % (len(qs), 
user_account.username))
+    
+    history = []
+
+    for entry in qs:
+
+        counterpart = entry.credit_account.user.username
+        sign = "-"
+
+        if entry.credit_account.user.username == user_account.username:
+            counterpart = entry.debit_account.user.username
+            sign = "+"
 
+        history.append(dict(counterpart=counterpart,
+                            amount=entry.amount_obj,
+                            sign=sign))
+    logger.info(json.dumps(history))
     return HttpResponse(200)
 
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]