summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2019-05-23 14:24:38 +0200
committerMarcello Stanisci <stanisci.m@gmail.com>2019-05-23 14:24:38 +0200
commitef37242e94698d13ecdf2448c77a0fc3148918cb (patch)
tree49ad8d6d48b843ac001cd201cf6b5c9fb5fe51a5
parenta670306272f7ab051672ca8b721e7ac2e8e29d2a (diff)
downloadbank-stable.tar.gz
bank-stable.tar.bz2
bank-stable.zip
Remove (breaking) call to old API.stable
-rw-r--r--talerbank/app/tests.py21
-rw-r--r--talerbank/app/views.py14
2 files changed, 30 insertions, 5 deletions
diff --git a/talerbank/app/tests.py b/talerbank/app/tests.py
index 2aa1c57..3a8dc26 100644
--- a/talerbank/app/tests.py
+++ b/talerbank/app/tests.py
@@ -48,6 +48,27 @@ def clear_db():
cursor.execute(
"ALTER SEQUENCE app_banktransaction_id_seq RESTART")
+class PublicAccountsTestCase(TestCase):
+ def setUp(self):
+ clear_db()
+ self.user = User.objects.create_user(
+ username="Bank",
+ password="Bank")
+ self.user.save()
+
+ self.user_bank_account = BankAccount(
+ account_no=100,
+ is_public = True,
+ user=self.user)
+
+ self.user_bank_account.save()
+
+ def test_public_accounts(self):
+ self.assertTrue(User.objects.get(username="Bank"))
+
+ response = self.client.get(
+ reverse("public-accounts", urlconf=urls))
+
class WithdrawTestCase(TestCase):
def setUp(self):
self.user_bank_account = BankAccount(
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 8f97acf..f4af47c 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -509,10 +509,14 @@ def serve_public_accounts(request, name=None, page=None):
if not user.bankaccount.is_public:
raise PrivateAccountException("Can't display public history for private account")
- num_records = query_history_raw(user.bankaccount,
- "both",
- start=-1, # makes sign ignored.
- sign="+").count()
+ # How many records does a user have.
+ num_records = query_history(user.bankaccount,
+ "both",
+ # Note: the parameter below is used for slicing arrays
+ # and django/python is not allowing slicing with big numbers.
+ (UINT64_MAX / 2 ) / 2,
+ start=0,
+ sign="+").count()
DELTA = 30
# '//' operator is NO floating point.
num_pages = max(num_records // DELTA, 1)
@@ -523,7 +527,7 @@ def serve_public_accounts(request, name=None, page=None):
history = extract_history(user.bankaccount,
True,
DELTA * page,
- -1,
+ 0,
"+")[DELTA * (page - 1):(DELTA * page)]
pages = list(range(1, num_pages + 1))