summaryrefslogtreecommitdiff
path: root/talerbank/app/middleware.py
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-08-28 21:36:51 +0200
committerFlorian Dold <florian.dold@gmail.com>2019-08-28 21:36:51 +0200
commit4e569d7584c6a128ab685fc9ca0539139df8bca4 (patch)
treebe604a5580f8a6096827fa02240ca466674c8777 /talerbank/app/middleware.py
parentd95ade12b327e36994d628722be05c4b101c2eae (diff)
downloadbank-4e569d7584c6a128ab685fc9ca0539139df8bca4.tar.gz
bank-4e569d7584c6a128ab685fc9ca0539139df8bca4.tar.bz2
bank-4e569d7584c6a128ab685fc9ca0539139df8bca4.zip
format code with yapf
Diffstat (limited to 'talerbank/app/middleware.py')
-rw-r--r--talerbank/app/middleware.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/talerbank/app/middleware.py b/talerbank/app/middleware.py
index e2ba00b..1af6f06 100644
--- a/talerbank/app/middleware.py
+++ b/talerbank/app/middleware.py
@@ -51,6 +51,7 @@ class DecompressionMiddleware:
return self.get_response(request)
+
##
# Class holding data needed by the handling logic.
class ExceptionMiddleware:
@@ -89,7 +90,8 @@ class ExceptionMiddleware:
LoginFailed: 12,
RejectNoRightsException: 13,
NumberTooBig: 1,
- NegativeNumber: 0}
+ NegativeNumber: 0
+ }
# List of all the HTTP endpoint that are likely
# to generate exceptions.
@@ -98,8 +100,8 @@ class ExceptionMiddleware:
"/taler/withdraw": 5500,
"/reject": 5300,
"/history": 5200,
- "/admin/add/incoming": 5100}
-
+ "/admin/add/incoming": 5100
+ }
# Map between endpoints and Web pages to render
# after the exception gets managed.
@@ -108,7 +110,8 @@ class ExceptionMiddleware:
"/register": "index",
"/public-accounts": "index",
"/pin/verify": "profile",
- "/withdraw": "profile"}
+ "/withdraw": "profile"
+ }
##
# This function is transparently invoked by Django when
@@ -140,7 +143,7 @@ class ExceptionMiddleware:
break
if not exc_class:
return None
-
+
# Managed exception. Build response.
taler_ec = self.excs.get(exc_class)
@@ -167,11 +170,14 @@ class ExceptionMiddleware:
http_status_code = 404
if not render_to:
- return JsonResponse({"ec": taler_ec,
- "error": hint},
+ return JsonResponse({
+ "ec": taler_ec,
+ "error": hint
+ },
status=http_status_code)
request.session["profile_hint"] = \
True, False, exception.hint
return redirect(render_to)
+
# [1] https://git.taler.net/exchange.git/tree/src/include/taler_error_codes.h#n1502