[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-bank] branch master updated: Build history response
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-bank] branch master updated: Build history response in a separate helper. |
Date: |
Tue, 02 Apr 2019 18:41:10 +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 5bde353 Build history response in a separate helper.
5bde353 is described below
commit 5bde353f16d98fd01ba95dc2253e690a607c8ed3
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Apr 2 18:40:44 2019 +0200
Build history response in a separate helper.
---
talerbank/app/views.py | 57 +++++++++++++++++++++++++++++++-------------------
1 file changed, 35 insertions(+), 22 deletions(-)
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 2914341..fd8ec2a 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -346,8 +346,6 @@ def pin_tan_question(request):
return render(request, "pin_tan.html", context)
-
-
##
# This method serves the user's answer to the math CAPTCHA,
# and reacts accordingly to its correctness. If correct (wrong),
@@ -620,6 +618,38 @@ def query_history(bank_account,
##
+# Build response object for /history.
+#
+# @param qs the query set for a history request.
+# @param cancelled controls whether we omit/show
+# cancelled transactions.
+# @param user_account bank account of the user who
+# asked for the history.
+# @return the history object as specified in the
+# API reference documentation.
+def build_history_response(qs, cancelled, user_account):
+ history = []
+ 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
+ sign_ = "+"
+ cancel = "cancel" if entry.cancelled else ""
+ sign_ = cancel + sign_
+ history.append(dict(
+ counterpart=counterpart,
+ amount=entry.amount.dump(),
+ sign=sign_,
+ wt_subject=entry.subject,
+ row_id=entry.id,
+ date="/Date("+str(int(entry.date.timestamp()))+")/"))
+ return history
+
+##
# Serve a request of /history.
#
# @param request Django-specific HTTP request.
@@ -651,26 +681,9 @@ def serve_history(request, user_account):
sign,
"descending" == ordering)
- history = []
- cancelled = request.GET.get("cancelled", "show")
- 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
- sign_ = "+"
- cancel = "cancel" if entry.cancelled else ""
- sign_ = cancel + sign_
- history.append(dict(
- counterpart=counterpart,
- amount=entry.amount.dump(),
- sign=sign_,
- wt_subject=entry.subject,
- row_id=entry.id,
- date="/Date("+str(int(entry.date.timestamp()))+")/"))
+ history = build_history_response(qs,
+ request.GET.get("cancelled", "show"),
+ user_account)
if not history:
return HttpResponse(status=204)
return JsonResponse(dict(data=history), status=200)
--
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: Build history response in a separate helper.,
gnunet <=