File tree Expand file tree Collapse file tree 5 files changed +81
-2
lines changed Expand file tree Collapse file tree 5 files changed +81
-2
lines changed Original file line number Diff line number Diff line change 11import os
22import subprocess
3- from flask import Flask
4- from flask import redirect
3+ from flask import Flask , redirect , request
54from flask_sqlalchemy import SQLAlchemy
65from flask_migrate import Migrate
76from csh_ldap import CSHLDAP
5251app .register_blueprint (slideshow_bp )
5352app .register_blueprint (cache_bp )
5453
54+ from conditional .util .flask import render_template
55+ from conditional .util .ldap import ldap_get_member
5556
5657@app .route ('/<path:path>' )
5758def static_proxy (path ):
@@ -63,6 +64,20 @@ def static_proxy(path):
6364def default_route ():
6465 return redirect ('/dashboard' )
6566
67+ @app .errorhandler (404 )
68+ @app .errorhandler (500 )
69+ def route_errors (error ):
70+ username = request .headers .get ('x-webauth-user' )
71+ member = ldap_get_member (username )
72+ data = dict ()
73+ data ['username' ] = member .uid
74+ data ['name' ] = member .cn
75+ code = error .code
76+ return render_template (request = request ,
77+ template_name = '404.html' ,
78+ error = str (error ),
79+ error_code = code ,
80+ ** data ), 404
6681
6782@app .cli .command ()
6883def zoo ():
Original file line number Diff line number Diff line change 1+ {% extends "nav.html" %}
2+ {% block title %}
3+ {{ error_code }}
4+ {% endblock %}
5+ {% block body %}
6+ < div class ="container main error-page align-center ">
7+ < div class ="col-xs-12 ">
8+ < img src ="/static/images/material_attention.svg " alt ="Attention! ">
9+ < h1 > Congratulations or I'm Sorry...</ h1 >
10+ < h2 > Something has gone terribly wrong!</ h2 >
11+ < h3 > The following error has been reported:</ h3 >
12+ < p > {{ error }}</ p >
13+ </ div >
14+ </ div >
15+ {% endblock %}
Original file line number Diff line number Diff line change 2525@import ' pages/management' ;
2626@import ' pages/hm-attendance' ;
2727@import ' pages/attendance-hist' ;
28+ @import ' pages/errors' ;
2829@import ' components/reveal' ;
Original file line number Diff line number Diff line change 1+ .error-page {
2+ padding-top : 80px ;
3+
4+ .glyphicon ,
5+ h1 ,
6+ h2 ,
7+ h3 ,
8+ p {
9+ color : #878787 ;
10+ }
11+
12+ img {
13+ margin-bottom : 40px ;
14+ width : 200px ;
15+ }
16+
17+ h1 {
18+ font-size : 50px ;
19+ font-weight : bolder ;
20+ }
21+
22+ h2 {
23+ margin-bottom : 80px ;
24+ font-size : 30px ;
25+ }
26+
27+ h3 {
28+ margin : 0 ;
29+ font-size : 25px ;
30+ }
31+
32+ p {
33+ font-size : 20px ;
34+ font-weight : lighter ;
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments