gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-bank] branch stable updated (08503be -> 57b11ae)


From: gnunet
Subject: [GNUnet-SVN] [taler-bank] branch stable updated (08503be -> 57b11ae)
Date: Tue, 20 Feb 2018 12:01:39 +0100

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

dold pushed a change to branch stable
in repository bank.

    from 08503be  autofocus and style
     add 9a72541  changelog
     add 3e2ddde  right version in autoconf
     add a9c36c8  remove old stuff from "dist"
     add 4b4f08c  squashing all migrations, keeping the old ones around (as 
suggested by Django) even though they are seemingly not used anymore..
     add f6db5e0  properly "dist"-ing the squashed migration.
     add 2ccd46c  adding new entries to "make dist".
     add c14d6c9  Do not use cookies for pagination, fix/simplify logic
     add 57b11ae  syntax/typo

No new revisions were added by this update.

Summary of changes:
 ChangeLog                            |  5 +++
 Makefile.am                          |  1 -
 configure.ac                         |  2 +-
 talerbank/app/Makefile.am            |  4 +-
 talerbank/app/migrations/Makefile.am |  4 +-
 talerbank/app/static/Makefile.am     |  4 +-
 talerbank/app/views.py               | 79 +++++++++++++++---------------------
 7 files changed, 44 insertions(+), 55 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ff7ace9..add810a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Feb 13 10:05:06 CET 2018
+        Introducing the /reject REST API, internal wire
+        transfers between users, and a middleware-based
+        exceptions management.
+
 Thu Jul 13 11:43:05 CEST 2017
         Testing against ill-formed config file
 
diff --git a/Makefile.am b/Makefile.am
index 012f7b2..c6f5581 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,7 +14,6 @@ EXTRA_DIST = \
  bank.conf \
  bank-check.conf \
  bank-check-alt-badamount.conf \
- bank-check-alt-baddb.conf \
  bank-check-alt-nocurrency.conf
 
 pkgcfgdir= $(prefix)/share/taler/config.d/
diff --git a/configure.ac b/configure.ac
index 4904365..f242d92 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
 # This script is in the public domain.
 AC_PREREQ(2.61)
-AC_INIT([taler-bank], [0.4.0], address@hidden)
+AC_INIT([taler-bank], [0.5.0], address@hidden)
 
 AC_CONFIG_MACRO_DIR([m4])
 
diff --git a/talerbank/app/Makefile.am b/talerbank/app/Makefile.am
index b3efdd7..0af3d65 100644
--- a/talerbank/app/Makefile.am
+++ b/talerbank/app/Makefile.am
@@ -6,8 +6,8 @@ EXTRA_DIST = \
   urls.py \
   views.py \
   amount.py \
-  checks.py  \
   __init__.py \
   models.py \
   tests.py \
-  tests_alt.py
+  tests_alt.py \
+  middleware.py
diff --git a/talerbank/app/migrations/Makefile.am 
b/talerbank/app/migrations/Makefile.am
index ccbed84..c2817bd 100644
--- a/talerbank/app/migrations/Makefile.am
+++ b/talerbank/app/migrations/Makefile.am
@@ -1,5 +1,5 @@
 SUBDIRS = .
 
 EXTRA_DIST = \
-  0001_initial.py \
-  __init__.py
+0001_squashed_0013_remove_banktransaction_reimburses.py \
+__init__.py
diff --git a/talerbank/app/static/Makefile.am b/talerbank/app/static/Makefile.am
index 3b4f1cf..b393a6c 100644
--- a/talerbank/app/static/Makefile.am
+++ b/talerbank/app/static/Makefile.am
@@ -2,5 +2,5 @@ SUBDIRS = . web-common
 
 EXTRA_DIST = \
   favicon.ico \
-  chrome-store-link.js \
-  bank.css
+  bank.css \
+  disabled-button.css
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 55686ce..2dd121e 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -48,6 +48,10 @@ class LoginFailed(Exception):
     hint = "Wrong username/password"
     http_status_code = 401
 
+class PrivateAccountException(Exception):
+    hint = "The selected account is private"
+    http_status_code = 402
+
 class DebitLimitException(Exception):
     hint = "Debit too high, operation forbidden."
     http_status_code = 403
@@ -346,7 +350,6 @@ def extract_history(account, delta=None, start=-1, 
sign="+"):
 
 
 def serve_public_accounts(request, name=None, page=None):
-    
     try:
         page = int(page)
     except Exception:
@@ -355,54 +358,28 @@ def serve_public_accounts(request, name=None, page=None):
     if not name:
         name = settings.TALER_PREDEFINED_ACCOUNTS[0]
     user = User.objects.get(username=name)
+    if not user.bankaccount.is_public:
+        raise PrivateAccountException("Can't display public history for 
private account")
 
-    if "public_history_count" not in request.session:
-        qs = extract_history(user.bankaccount, sign="-")
-        youngest = -1
-        if qs:
-            youngest = qs[0]["row_id"]
-        request.session["public_history_account"] = \
-            len(qs), youngest
+    num_records = query_history_raw(user.bankaccount, "both", start=-1, 
sign="-").count()
 
     DELTA = 30
-    youngest = request.session["public_history_account"][1]
-    # normalize page
-    if not page or page in [0, 1]:
-        page = 1
-    # page 0 and 1 give both the youngest 100 records.
-    if page > 1:
-        youngest = youngest - (DELTA * (page - 1)) # goes backwards.
-    if not user.bankaccount.is_public:
-        request.session["public_accounts_hint"] = \
-            True, False, "Could not query private accounts!"
-    fail_message, success_message, hint = \
-        get_session_hint(request, "public_accounts_hint")
-    public_accounts = BankAccount.objects.filter(is_public=True)
+    youngest = 1 + DELTA * (page - 1)
 
-    # Retrieve DELTA records older than 'start'.
-    history = extract_history(
-        user.bankaccount, DELTA,
-        -1 if youngest < 2 else youngest, "-")
+    public_accounts = BankAccount.objects.filter(is_public=True)
 
-    num_pages = max(
-        request.session["public_history_account"][0] / DELTA,
-        1) # makes sure pages[0] exists, below.
+    # Retrieve DELTA records, starting from 'youngest'
+    history = extract_history(user.bankaccount, DELTA, youngest - 1, "+")
 
-    pages = list(
-        range(max(1, page - 3),
-              # need +1 because the range is not inclusive for
-              # the upper limit.
-              min(page + 4, (math.ceil(num_pages) + 1))))
+    num_pages = max(num_records // DELTA, 1)
+    pages = list(range(1, num_pages + 1))
 
     context = dict(
         current_page=page,
-        back = page - 1 if pages[0] > 1 else None,
-        forth = page + 1 if pages[-1] < num_pages else None,
+        back = page - 1 if page > 1 else None,
+        forth = page + 1 if page < num_pages else None,
         public_accounts=public_accounts,
         selected_account=dict(
-            fail_message=fail_message,
-            success_message=success_message,
-            hint=hint,
             name=name,
             number=user.bankaccount.account_no,
             history=history,
@@ -411,6 +388,7 @@ def serve_public_accounts(request, name=None, page=None):
     )
     return render(request, "public_accounts.html", context)
 
+
 def login_via_headers(view_func):
     def _decorator(request, *args, **kwargs):
         user_account = auth_and_login(request)
@@ -436,15 +414,23 @@ def login_via_headers(view_func):
 #   than 'start'.
 
 def query_history(bank_account, direction, delta, start, sign):
+    qs = query_history_raw(bank_account, direction, start, sign)
+    # '-id' does descending ordering.
+    ordering = "-id" if sign in ["-", "*"] else "id"
+    return qs.order_by(ordering)[:delta]
+
+
+def query_history_raw(bank_account, direction, start, sign):
     direction_switch = {
-        "both": Q(debit_account=bank_account) \
-                | Q(credit_account=bank_account),
+        "both": (Q(debit_account=bank_account) |
+                 Q(credit_account=bank_account)),
         "credit": Q(credit_account=bank_account),
         "debit": Q(debit_account=bank_account),
-        "cancel+": Q(credit_account=bank_account) \
-                      & Q(cancelled=True),
-        "cancel-": Q(debit_account=bank_account) \
-                      & Q(cancelled=True)}
+        "cancel+": (Q(credit_account=bank_account) &
+                    Q(cancelled=True)),
+        "cancel-": (Q(debit_account=bank_account) &
+                    Q(cancelled=True)),
+    }
 
     sign_filter = {
         "+": Q(id__gt=start),
@@ -457,9 +443,8 @@ def query_history(bank_account, direction, delta, start, 
sign):
 
     return BankTransaction.objects.filter(
         direction_switch.get(direction),
-        sign_filter.get(sign)).order_by(
-            # '-id' does descending ordering.
-            "-id" if sign in ["-", "*"] else "id")[:delta]
+        sign_filter.get(sign));
+
 
 @require_GET
 @login_via_headers

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



reply via email to

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