From 2eb06181da9c187bd057740180019b6fa53ecd53 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Oct 16 2014 08:31:52 +0000 Subject: Add error pages --- diff --git a/progit/__init__.py b/progit/__init__.py index dc1270f..f45e2be 100644 --- a/progit/__init__.py +++ b/progit/__init__.py @@ -390,6 +390,24 @@ def set_user(return_url): return flask.redirect(return_url) +@APP.errorhandler(404) +def not_found(error): + """404 Not Found page""" + return flask.render_template('not_found.html'), 404 + + +@APP.errorhandler(500) +def fatal_error(error): + """500 Fatal Error page""" + return flask.render_template('fatal_error.html'), 500 + + +@APP.errorhandler(401) +def unauthorized(error): + """401 Unauthorized page""" + return flask.render_template('unauthorized.html'), 401 + + @APP.route('/login/', methods=('GET', 'POST')) def auth_login(): """ Method to log into the application using FAS OpenID. """ diff --git a/progit/static/progit.css b/progit/static/progit.css index d4c6d51..8eafa69 100644 --- a/progit/static/progit.css +++ b/progit/static/progit.css @@ -495,3 +495,7 @@ a.button:visited, a.button:hover { border: 1px solid rgba(237, 237, 237, 0.4); border-radius: 10px 10px 0 0; } + +[id=error] h2 { + color: red; +} diff --git a/progit/templates/fatal_error.html b/progit/templates/fatal_error.html new file mode 100644 index 0000000..3362a8f --- /dev/null +++ b/progit/templates/fatal_error.html @@ -0,0 +1,10 @@ +{% extends "master.html" %} + +{% block title %}A fatal error occured :'({% endblock %} +{%block tag %}error{% endblock %} + + +{% block content %} +

Fatal Error (500)

+

A fatal error has been throwed, we're sorry :(

+{% endblock %} diff --git a/progit/templates/not_found.html b/progit/templates/not_found.html new file mode 100644 index 0000000..48cedbe --- /dev/null +++ b/progit/templates/not_found.html @@ -0,0 +1,12 @@ +{% extends "master.html" %} + +{% block title %}Page not found :'({% endblock %} +{%block tag %}error{% endblock %} + + +{% block content %} +

Page not found (404)

+

The requested page cannot be found, we're sorry :(

+

Maybe you enter a bad URL, or the page has moved or has been removed, or...
+ Use the main navigation menu to get (re)started.

+{% endblock %} diff --git a/progit/templates/unauthorized.html b/progit/templates/unauthorized.html new file mode 100644 index 0000000..fc336a9 --- /dev/null +++ b/progit/templates/unauthorized.html @@ -0,0 +1,12 @@ +{% extends "master.html" %} + +{% block title %}Unauthorized :'({% endblock %} +{%block tag %}error{% endblock %} + + +{% block content %} +

Unauthorized (401)

+

You are not authorized to display the requested page.

+

If you're not logged in, try to login; if you're already done, + that probably means you do not have sufficient access.

+{% endblock %}