From 4e569d7584c6a128ab685fc9ca0539139df8bca4 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 28 Aug 2019 21:36:51 +0200 Subject: format code with yapf --- talerbank/app/middleware.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'talerbank/app/middleware.py') 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 -- cgit v1.2.3