summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYingtong Li <runassudo@yingtongli.me>2020-06-16 12:14:49 +1000
committerYingtong Li <runassudo@yingtongli.me>2020-06-16 12:17:18 +1000
commitb2913eac9d6e42a60c88dde5d2137257be3a94e3 (patch)
tree3c266115f91902ecaa9adb59efaacfbf8fba7597
parent10f0cd4121c2e920ff18e7c02b8ceefd7d8ccb5d (diff)
Show BSB lookup on claim page
-rw-r--r--sstreasury/jinja2/sstreasury/claim_print.html7
-rw-r--r--sstreasury/jinja2/sstreasury/claim_view.html7
-rw-r--r--sstreasury/views.py20
3 files changed, 26 insertions, 8 deletions
diff --git a/sstreasury/jinja2/sstreasury/claim_print.html b/sstreasury/jinja2/sstreasury/claim_print.html
index 6616edd..f29343a 100644
--- a/sstreasury/jinja2/sstreasury/claim_print.html
+++ b/sstreasury/jinja2/sstreasury/claim_print.html
@@ -87,7 +87,12 @@
</div>
<div class="item">
<i class="building icon"></i>
- <div class="content">BSB: {{ claim.payee_bsb }}</div>
+ <div class="content">
+ BSB: {{ claim.payee_bsb }}
+ {% if bsb_lookedup %}
+ ({{ bsb_lookedup }})
+ {% endif %}
+ </div>
</div>
<div class="item">
<i class="dollar sign icon"></i>
diff --git a/sstreasury/jinja2/sstreasury/claim_view.html b/sstreasury/jinja2/sstreasury/claim_view.html
index 937bffd..78b36d6 100644
--- a/sstreasury/jinja2/sstreasury/claim_view.html
+++ b/sstreasury/jinja2/sstreasury/claim_view.html
@@ -122,7 +122,12 @@
</div>
<div class="item">
<i class="building icon"></i>
- <div class="content">BSB: {{ claim.payee_bsb }}</div>
+ <div class="content">
+ BSB: {{ claim.payee_bsb }}
+ {% if bsb_lookedup %}
+ ({{ bsb_lookedup }})
+ {% endif %}
+ </div>
</div>
<div class="item">
<i class="dollar sign icon"></i>
diff --git a/sstreasury/views.py b/sstreasury/views.py
index d3b1d7c..af809e0 100644
--- a/sstreasury/views.py
+++ b/sstreasury/views.py
@@ -520,10 +520,13 @@ def claim_view(request, claim):
except models.Budget.DoesNotExist:
budget = None
+ bsb_lookedup = do_bsb_lookup(claim.payee_bsb)
+
return render(request, 'sstreasury/claim_view.html', {
'claim': claim,
'budget': budget,
- 'history': history
+ 'history': history,
+ 'bsb_lookedup': bsb_lookedup
})
@login_required
@@ -537,9 +540,12 @@ def claim_print(request, claim):
except models.Budget.DoesNotExist:
budget = None
+ bsb_lookedup = do_bsb_lookup(claim.payee_bsb)
+
return render(request, 'sstreasury/claim_print.html', {
'claim': claim,
- 'budget': budget
+ 'budget': budget,
+ 'bsb_lookedup': bsb_lookedup
})
@login_required
@@ -728,12 +734,14 @@ def claim_processing(request):
@login_required
def bsb_lookup(request):
- bsb = request.GET.get('bsb', '').replace('-', '').replace(' ', '')
- if len(bsb) != 6:
- return JsonResponse({'result': None})
- return JsonResponse({'result': do_bsb_lookup(bsb[:3] + '-' + bsb[-3:])})
+ return JsonResponse({'result': do_bsb_lookup(request.GET.get('bsb', ''))})
def do_bsb_lookup(bsb):
+ bsb = (bsb or '').replace('-', '').replace(' ', '')
+ if len(bsb) != 6:
+ return None
+ bsb = '{}-{}'.format(bsb[:3], bsb[-3:])
+
with open(settings.BSB_FILE_PATH, 'r', newline='') as f:
reader = csv.reader(f)
for line in reader:
Contact (issues, pull requests, etc.) at git@yingtongli.me. Generated by cgit.