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 1
1
import os
2
2
import subprocess
3
- from flask import Flask
4
- from flask import redirect
3
+ from flask import Flask , redirect , request
5
4
from flask_sqlalchemy import SQLAlchemy
6
5
from flask_migrate import Migrate
7
6
from csh_ldap import CSHLDAP
52
51
app .register_blueprint (slideshow_bp )
53
52
app .register_blueprint (cache_bp )
54
53
54
+ from conditional .util .flask import render_template
55
+ from conditional .util .ldap import ldap_get_member
55
56
56
57
@app .route ('/<path:path>' )
57
58
def static_proxy (path ):
@@ -63,6 +64,20 @@ def static_proxy(path):
63
64
def default_route ():
64
65
return redirect ('/dashboard' )
65
66
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
66
81
67
82
@app .cli .command ()
68
83
def 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 25
25
@import ' pages/management' ;
26
26
@import ' pages/hm-attendance' ;
27
27
@import ' pages/attendance-hist' ;
28
+ @import ' pages/errors' ;
28
29
@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