diff options
| author | 2018-03-04 16:33:01 +0000 | |
|---|---|---|
| committer | 2018-03-04 16:33:01 +0000 | |
| commit | 5099ae7055b313d1a93d53069c2cfbb0ca0dcf5a (patch) | |
| tree | e8d4b781a38b17502f24e1fd9f444926e88544d6 /pysite/views/error_handlers | |
| parent | Fix navbar dropdown (diff) | |
Info pages #13xan #13xak (#36)
* Info pages and templates
* Info pages and templates
* Info pages and templates
* Update navigation and fix up HTML
* Navigation HTML spacing for readability
* Fix error views not using `self.render()`
* `render()` method should accept Any for context values
* Change header linking CSS to a dedicated class
* Rules page
* Basic resources page setup
* Fix headers for new CSS class
* Resource categories and initial resource data
* Add link to JSON file on GH - won't work until the branch is merged
* Remove info overview page and redirect info root url to resources
* Flake8
* Add some tests
* Line lengths
Diffstat (limited to 'pysite/views/error_handlers')
| -rw-r--r-- | pysite/views/error_handlers/http_4xx.py | 24 | ||||
| -rw-r--r-- | pysite/views/error_handlers/http_5xx.py | 39 |
2 files changed, 29 insertions, 34 deletions
diff --git a/pysite/views/error_handlers/http_4xx.py b/pysite/views/error_handlers/http_4xx.py index 5717feae..74d43d6c 100644 --- a/pysite/views/error_handlers/http_4xx.py +++ b/pysite/views/error_handlers/http_4xx.py @@ -1,5 +1,5 @@ # coding=utf-8 -from flask import render_template, request +from flask import request from werkzeug.exceptions import HTTPException from pysite.base_route import ErrorView @@ -13,17 +13,19 @@ class Error400View(ErrorView): def get(self, error: HTTPException): error_desc = ERROR_DESCRIPTIONS.get(error.code, "We're not really sure what happened there, please try again.") - return render_template("errors/error.html", code=error.code, req=request, error_title=error_desc, - error_message=error_desc + - " If you believe we have made a mistake, please " - "<a href='https://github.com" - "/discord-python/site/issues'>open an issue on our GitHub</a>."), error.code + return self.render( + "errors/error.html", code=error.code, req=request, error_title=error_desc, + error_message=error_desc + + " If you believe we have made a mistake, please " + "<a href='https://github.com/discord-python/site/issues'>open an issue on our GitHub</a>." + ), error.code def post(self, error: HTTPException): error_desc = ERROR_DESCRIPTIONS.get(error.code, "We're not really sure what happened there, please try again.") - return render_template("errors/error.html", code=error.code, req=request, error_title=error_desc, - error_message=error_desc + - " If you believe we have made a mistake, please " - "<a href='https://github.com" - "/discord-python/site/issues'>open an issue on our GitHub</a>."), error.code + return self.render( + "errors/error.html", code=error.code, req=request, error_title=error_desc, + error_message=error_desc + + " If you believe we have made a mistake, please " + "<a href='https://github.com/discord-python/site/issues'>open an issue on our GitHub</a>." + ), error.code diff --git a/pysite/views/error_handlers/http_5xx.py b/pysite/views/error_handlers/http_5xx.py index 6bbc8275..60d3b1bb 100644 --- a/pysite/views/error_handlers/http_5xx.py +++ b/pysite/views/error_handlers/http_5xx.py @@ -1,5 +1,5 @@ # coding=utf-8 -from flask import render_template, request +from flask import request from werkzeug.exceptions import HTTPException from pysite.base_route import ErrorView @@ -13,28 +13,21 @@ class Error500View(ErrorView): def get(self, error: HTTPException): error_desc = ERROR_DESCRIPTIONS.get(error.code, "We're not really sure what happened there, please try again.") - return render_template("errors/error.html", code=error.code, req=request, error_title=error_desc, - error_message="An error occurred while " - "processing this " - "request, please try " - "again later. " - "If you believe we have made a mistake, " - "please " - "<a href='https://github.com" - "/discord-python/site/issues'>file an issue on our GitHub" - "</a>."), error.code + return self.render( + "errors/error.html", code=error.code, req=request, error_title=error_desc, + error_message="An error occurred while processing this request, please try " + "again later. If you believe we have made a mistake, please " + "<a href='https://github.com/discord-python/site/issues'>file an issue on our" + " GitHub</a>." + ), error.code def post(self, error: HTTPException): - error_desc = ERROR_DESCRIPTIONS.get(error.code, - "We're not really sure what happened there, please try again.") + error_desc = ERROR_DESCRIPTIONS.get(error.code, "We're not really sure what happened there, please try again.") - return render_template("errors/error.html", code=error.code, req=request, error_title=error_desc, - error_message="An error occurred while " - "processing this " - "request, please try " - "again later. " - "If you believe we have made a mistake, " - "please " - "<a href='https://github.com" - "/discord-python/site/issues'>file an issue on our GitHub" - "</a>."), error.code + return self.render( + "errors/error.html", code=error.code, req=request, error_title=error_desc, + error_message="An error occurred while processing this request, please try " + "again later. If you believe we have made a mistake, please " + "<a href='https://github.com/discord-python/site/issues'>file an issue on our" + " GitHub</a>." + ), error.code |