From d21ff6cafa7bf2b4d83bad836033a7f2724db754 Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Thu, 13 Apr 2023 16:24:49 +0200 Subject: [PATCH 1/2] added customization for error pages --- caimira/apps/calculator/__init__.py | 17 ++++++----------- caimira/apps/static/css/style.css | 16 +++++++++++++++- caimira/apps/templates/about.html.j2 | 2 +- .../templates/base/calculator.report.html.j2 | 1 + caimira/apps/templates/base/layout.html.j2 | 2 +- caimira/apps/templates/error.html.j2 | 19 +++++++++++++++++++ 6 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 caimira/apps/templates/error.html.j2 diff --git a/caimira/apps/calculator/__init__.py b/caimira/apps/calculator/__init__.py index 3da5f048..f8be0a45 100644 --- a/caimira/apps/calculator/__init__.py +++ b/caimira/apps/calculator/__init__.py @@ -57,16 +57,9 @@ class BaseRequestHandler(RequestHandler): def write_error(self, status_code: int, **kwargs) -> None: template = self.settings["template_environment"].get_template( - "page.html.j2") + "error.html.j2") error_id = uuid.uuid4() - contents = ( - f'Unfortunately an error occurred when processing your request. ' - f'Please let us know about this issue with as much detail as possible at ' - f'CAiMIRA-dev@cern.ch, reporting status ' - f'code {status_code}, the error id of "{error_id}" and the time of the ' - f'request ({datetime.datetime.utcnow()}).



' - ) # Print the error to the log (and not to the browser!) if "exc_info" in kwargs: print(f"ERROR UUID {error_id}") @@ -76,7 +69,9 @@ class BaseRequestHandler(RequestHandler): get_url = template.globals['get_url'], get_calculator_url = template.globals["get_calculator_url"], active_page='Error', - contents=contents + error_id=error_id, + status_code=status_code, + datetime=datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S"), )) @@ -85,13 +80,13 @@ class Missing404Handler(BaseRequestHandler): await super().prepare() self.set_status(404) template = self.settings["template_environment"].get_template( - "page.html.j2") + "error.html.j2") self.finish(template.render( user=self.current_user, get_url = template.globals['get_url'], get_calculator_url = template.globals["get_calculator_url"], active_page='Error', - contents='Unfortunately the page you were looking for does not exist.



' + status_code=404, )) diff --git a/caimira/apps/static/css/style.css b/caimira/apps/static/css/style.css index fddd7503..e7b733d2 100644 --- a/caimira/apps/static/css/style.css +++ b/caimira/apps/static/css/style.css @@ -15,10 +15,13 @@ p { } /*-- Body Reset --*/ -body { +html, body { /* overflow-x: hidden */ font-family: 'Montserrat', sans-serif; color: rgb(47, 72, 88); + display: flex; + flex-direction: column; + height: 100%; } /*============= TOP BAR HEADER =============*/ @@ -186,6 +189,17 @@ body { margin-right: 10px; } +.btn-caimira-color{ + color: rgb(42, 52, 66); + border-color: rgb(42, 52, 66); +} + +.btn-caimira-color:hover{ + color: white; + background-color: rgb(42, 52, 66); + +} + /*===== FIXED BACKGROUND IMG =====*/ .fixed-background { diff --git a/caimira/apps/templates/about.html.j2 b/caimira/apps/templates/about.html.j2 index 36ea62e8..479acc4b 100644 --- a/caimira/apps/templates/about.html.j2 +++ b/caimira/apps/templates/about.html.j2 @@ -63,5 +63,5 @@ Although the user is able to calculate the infection probability of a stand-alon

- + {% endblock main %} diff --git a/caimira/apps/templates/base/calculator.report.html.j2 b/caimira/apps/templates/base/calculator.report.html.j2 index cba60719..020d40b5 100644 --- a/caimira/apps/templates/base/calculator.report.html.j2 +++ b/caimira/apps/templates/base/calculator.report.html.j2 @@ -651,6 +651,7 @@ {{ text_blocks['Disclaimer'] }} {% endblock disclaimer %} +
{% endblock disclaimer_container %} diff --git a/caimira/apps/templates/base/layout.html.j2 b/caimira/apps/templates/base/layout.html.j2 index 6a2f592c..6deef540 100644 --- a/caimira/apps/templates/base/layout.html.j2 +++ b/caimira/apps/templates/base/layout.html.j2 @@ -81,7 +81,7 @@ {% endblock main %} -