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: adding /history's 'canc


From: gnunet
Subject: [GNUnet-SVN] [taler-bank] branch master updated: adding /history's 'cancelled' argument
Date: Wed, 13 Dec 2017 19:49:30 +0100

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 98d4ef4  adding /history's 'cancelled' argument
98d4ef4 is described below

commit 98d4ef4ed341860df2abc8acf6cb4ae33b380e46
Author: Marcello Stanisci <address@hidden>
AuthorDate: Wed Dec 13 19:48:26 2017 +0100

    adding /history's 'cancelled' argument
---
 talerbank/app/schemas.py |  3 +++
 talerbank/app/tests.py   |  3 +++
 talerbank/app/views.py   | 12 +++++++-----
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/talerbank/app/schemas.py b/talerbank/app/schemas.py
index 810f33f..9e02400 100644
--- a/talerbank/app/schemas.py
+++ b/talerbank/app/schemas.py
@@ -88,6 +88,9 @@ HISTORY_REQUEST_SCHEMA = {
     "type": "object",
     "properties": {
         "auth": {"type": "string", "pattern": "^basic$"},
+        "cancelled": {"type": "string",
+                      "pattern": "^(omit|show)$",
+                      "required": False},
         "delta": {"type": "string",
                   "pattern": r"^([\+-])?([0-9])+$"},
         "start": {"type": "string",
diff --git a/talerbank/app/tests.py b/talerbank/app/tests.py
index 2c8729a..1957d9f 100644
--- a/talerbank/app/tests.py
+++ b/talerbank/app/tests.py
@@ -396,6 +396,9 @@ class HistoryTestCase(TestCase):
                         start=8, delta="+1", direction="cancel-"),
                     HistoryContext(
                         expected_resp={"status": 204},
+                        start=8, delta="+1", direction="cancel-", 
cancelled="omit"),
+                    HistoryContext(
+                        expected_resp={"status": 204},
                         start=8, delta="-1", direction="cancel-"),
                     HistoryContext(
                         expected_resp={"status": 204},
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index fc7fa2a..3537e7c 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -421,6 +421,7 @@ def serve_history(request, user_account):
         if sign == "-":
             sign_filter = Q(id__lt=start)
 
+
     direction_switch = {
         "both": Q(debit_account=user_account.bankaccount) \
                 | Q(credit_account=user_account.bankaccount),
@@ -435,16 +436,16 @@ def serve_history(request, user_account):
     # (and its value as switch's key) does exist here.
     query_string = direction_switch[request.GET["direction"]]
     history = []
-
+    cancelled = request.GET.get("cancelled", "show")
     qs = BankTransaction.objects.filter(
         query_string, sign_filter).order_by(
             "-id" if sign == "-" else "id") \
             [:int(parsed_delta.group(2))]
-    if qs.count() == 0:
-        return HttpResponse(status=204)
     for entry in qs:
         counterpart = entry.credit_account.account_no
         sign_ = "-"
+        if entry.cancelled and cancelled == "omit":
+            continue
         if entry.credit_account.account_no == \
                 user_account.bankaccount.account_no:
             counterpart = entry.debit_account.account_no
@@ -458,9 +459,10 @@ def serve_history(request, user_account):
             wt_subject=entry.subject,
             row_id=entry.id,
             date="/Date("+str(int(entry.date.timestamp()))+")/"))
+    if not history:
+        return HttpResponse(status=204)
     return JsonResponse(dict(data=history), status=200)
 
-
 def auth_and_login(request):
     """Return user instance after checking authentication
        credentials, False if errors occur"""
@@ -511,7 +513,7 @@ def reject(request, user_account):
     if trans.credit_account.account_no != \
             user_account.bankaccount.account_no:
         LOGGER.error("you can only reject a transaction where you"
-                     "_got_ money")
+                     " _got_ money")
         return JsonResponse(
             {"error": "you can only reject a transaction where"
                       " you _got_ money"},

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



reply via email to

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