diff options
author | Marcello Stanisci <stanisci.m@gmail.com> | 2018-01-16 11:51:12 +0100 |
---|---|---|
committer | Marcello Stanisci <stanisci.m@gmail.com> | 2018-01-16 11:51:12 +0100 |
commit | 91abe5eb99ff471fe981e3b2479341321b68fcd7 (patch) | |
tree | cba9d0533d7983f62b528f924b2423c53584ed9a | |
parent | 8d9993dffd5b21139515acbdc310cf7695de3ec3 (diff) | |
download | bank-91abe5eb99ff471fe981e3b2479341321b68fcd7.tar.gz bank-91abe5eb99ff471fe981e3b2479341321b68fcd7.tar.bz2 bank-91abe5eb99ff471fe981e3b2479341321b68fcd7.zip |
fix off-by-one /history error
-rw-r--r-- | talerbank/app/views.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/talerbank/app/views.py b/talerbank/app/views.py index 62f76b1..d5ad6fe 100644 --- a/talerbank/app/views.py +++ b/talerbank/app/views.py @@ -425,7 +425,9 @@ def login_via_headers(view_func): # 'delta': how many results are going to be extracted. If 'None' # is given, no filter of this kind will be applied. # 'start': a "id" indicating the first record to be returned. -# If -1 is given, then the first record will be the youngest. +# If -1 is given, then the first record will be the youngest +# and 'delta' records will be returned, _regardless_ of the +# 'sign' being passed. # 'sign': (+|-) indicating that we want records younger|older # than 'start'. @@ -443,15 +445,11 @@ def query_history(bank_account, direction, delta, start, sign): sign_filter = { "+": Q(id__gt=start), "-": Q(id__lt=start), - "*": Q(), - "x": not Q(), } # Handle special case. - if start == -1: # can only retrieve older records. - sign = "*" - if sign == "+": # no result is younger than the youngest. - sign = "x" + if start == -1: # return 'delta' youngest records. + sign = "+" return BankTransaction.objects.filter( direction_switch.get(direction), |