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: fix query string compos


From: gnunet
Subject: [GNUnet-SVN] [taler-bank] branch master updated: fix query string composition + related tests
Date: Fri, 05 May 2017 23:34:55 +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 9d304a5  fix query string composition + related tests
9d304a5 is described below

commit 9d304a56d971a765cfeeea962e2dc1d92aea33f0
Author: Marcello Stanisci <address@hidden>
AuthorDate: Fri May 5 23:34:27 2017 +0200

    fix query string composition + related tests
---
 talerbank/app/tests.py       |  2 +-
 talerbank/app/tests_admin.py |  2 +-
 talerbank/app/views.py       | 19 +++++++++----------
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/talerbank/app/tests.py b/talerbank/app/tests.py
index 96ac2dc..77aa3e0 100644
--- a/talerbank/app/tests.py
+++ b/talerbank/app/tests.py
@@ -102,7 +102,7 @@ class HistoryTestCase(TestCase):
     def test_history(self):
         c = Client()
         response = c.get(reverse("history", urlconf=urls), {"auth": "basic", 
"delta": "+4"},
-                         **{"X-Taler-Bank-Username": "User", 
"X-Taler-Bank-Password": "Password"})
+                         **{"HTTP_X_TALER_BANK_USERNAME": "User", 
"HTTP_X_TALER_BANK_PASSWORD": "Password"})
         self.assertEqual(200, response.status_code)
 
 
diff --git a/talerbank/app/tests_admin.py b/talerbank/app/tests_admin.py
index 9db35e3..9023952 100644
--- a/talerbank/app/tests_admin.py
+++ b/talerbank/app/tests_admin.py
@@ -59,5 +59,5 @@ class AddIncomingTestCase(TestCase):
         response = c.post(reverse("add-incoming", urlconf=urlsadmin),
                           data=data,
                           content_type="application/json",
-                          follow=True, **{"X-Taler-Bank-Username": 
"user_user", "X-Taler-Bank-Password": "user_password"})
+                          follow=True, **{"HTTP_X_TALER_BANK_USERNAME": 
"user_user", "HTTP_X_TALER_BANK_PASSWORD": "user_password"})
         self.assertEqual(200, response.status_code)
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index b841e58..beb131c 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -346,7 +346,7 @@ def history(request):
         parsed_delta.group(0)
     except AttributeError:
         return JasonResponse(dict(error="Bad 'delta' parameter"), status=400)
-    delta = parsed_delta.group(2)
+    delta = int(parsed_delta.group(2))
     # start
     start = request.GET.get("start")
 
@@ -367,14 +367,13 @@ def history(request):
     if not target_account:
         target_account = user_account.bankaccount
 
-    query_string = Q()
+    query_string = Q(debit_account=target_account) | 
Q(credit_account=target_account)
     history = []
 
-    if "credit" != direction:
-        query_string |= Q(debit_account=target_account)
-    if "debit" != direction:
-        query_string |= Q(credit_account=target_account)
-    query_string = sign & (query_string)
+    if "credit" == direction:
+        query_string = Q(credit_account=target_account)
+    if "debit" == direction:
+        query_string = Q(debit_account=target_account)
 
     qs = BankTransaction.objects.filter(query_string)[:delta]
     for entry in qs:
@@ -388,7 +387,7 @@ def history(request):
                             sign=sign,
                             subject=entry.subject))
 
-    return JsonResponse(history, 200)
+    return JsonResponse(dict(data=history), status=200)
 
 
 def auth_and_login(request):
@@ -410,8 +409,8 @@ def auth_and_login(request):
     
     logging.info(request.META.keys())
 
-    username = request.META["HTTP_X_TALER_BANK_USERNAME"]
-    password = request.META["HTTP_X_TALER_BANK_PASSWORD"]
+    username = request.META.get("HTTP_X_TALER_BANK_USERNAME")
+    password = request.META.get("HTTP_X_TALER_BANK_PASSWORD")
 
     logging.info("Authenticating '%s'/'%s'" % (username, password))
 

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



reply via email to

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