gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-bank] 01/05: sign & delta dealt with. testing needed


From: gnunet
Subject: [GNUnet-SVN] [taler-bank] 01/05: sign & delta dealt with. testing needed.
Date: Sat, 06 May 2017 22:30:43 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository bank.

commit 5168b652bdc8ea49c38522a4c708831a708f5345
Author: Marcello Stanisci <address@hidden>
AuthorDate: Sat May 6 21:26:45 2017 +0200

    sign & delta dealt with.  testing needed.
---
 talerbank/app/views.py | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index d88a763..62fa6be 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -350,19 +350,17 @@ def history(request):
     # start
     start = request.GET.get("start")
 
-    # sign (past/future) FIXME: if not given, the call
-    # must return the latest 'delta' entries: this code
-    # does not currently do that!
-    # The query should also apply some ordering to the
-    # records.
+    # FIXME: test 'delta' behaves well.
 
     sign = parsed_delta.group(1)
     if not start:
         sign = "-"
-    if "+" == sign:
-        sign = Q(id__gt=start)
-    else:
-        sign = Q(id__lt=start)
+    # Assuming Q() means 'true'
+    sign_filter = Q()
+    if "-" == sign and start:
+        sign_filter = Q(id__lt=start)
+    elif "+" == sign and start:
+        sign_filter = Q(id__gt=start)
 
     # direction (debit/credit)
     direction = request.GET.get("direction")
@@ -380,16 +378,17 @@ def history(request):
     if "debit" == direction:
         query_string = Q(debit_account=target_account)
 
-    qs = BankTransaction.objects.filter(query_string, sign)[:delta]
+    # FIXME problem with 'sign_filter'
+    qs = BankTransaction.objects.filter(query_string, 
sign_filter).order_by("%sid" % sign)[:delta]
     for entry in qs:
         counterpart = entry.credit_account.user.username
-        sign = "-"
+        sign_ = "-"
         if entry.credit_account.user.username == user_account.username:
             counterpart = entry.debit_account.user.username
-            sign = "+"
+            sign_ = "+"
         history.append(dict(counterpart=counterpart,
                             amount=entry.amount_obj,
-                            sign=sign,
+                            sign=sign_,
                             subject=entry.subject))
 
     return JsonResponse(dict(data=history), status=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]