Browse Source

Changed the routing rules naming system

Roland Haroutiounian 8 years ago
parent
commit
1b9cb1a72d

+ 14
- 4
plugins/webui/interface/controllers.py View File

5
 
5
 
6
 # This module contains the web UI controllers that will be called from the web ui class
6
 # This module contains the web UI controllers that will be called from the web ui class
7
 
7
 
8
-def get_response(tpl, mimetype = 'text/html', status_code = 200):
8
+
9
+def get_response(tpl, mimetype='text/html', status_code=200):
9
     loader = TemplateLoader()
10
     loader = TemplateLoader()
10
-    response = Response(    loader.render_to_response(tpl),
11
-                            mimetype = 'text/html')
11
+    response = Response(loader.render_to_response(tpl), mimetype=mimetype)
12
     response.status_code = status_code
12
     response.status_code = status_code
13
     return response
13
     return response
14
 
14
 
15
+
15
 def admin(request):
16
 def admin(request):
16
     return get_response('admin/admin.html')
17
     return get_response('admin/admin.html')
17
 
18
 
19
+
18
 def index(request):
20
 def index(request):
19
     return get_response('index/index.html')
21
     return get_response('index/index.html')
20
 
22
 
23
+
21
 def not_found(request):
24
 def not_found(request):
22
-    return get_response('errors/404.html', status_code = 404)
25
+    return get_response('errors/404.html', status_code=404)
26
+
23
 
27
 
24
 def test(request):
28
 def test(request):
25
     return get_response('test.html')
29
     return get_response('test.html')
30
+
31
+
32
+def list_classes(request):
33
+    # TODO Add the method to get the classes list
34
+
35
+    return get_response('list_classes.html')

+ 15
- 1
plugins/webui/interface/router.py View File

3
 
3
 
4
 from .controllers import *
4
 from .controllers import *
5
 from .urls import urls
5
 from .urls import urls
6
+from lodel.settings import Settings
7
+
8
+
9
+def format_url_rule(url_rule):
10
+    if url_rule == '^$':
11
+        return "^%s$" % Settings.sitename
12
+
13
+    formatted_rule = ''
14
+    if url_rule.startswith('^'):
15
+        formatted_rule += "^"
16
+
17
+    formatted_rule += "%s/%s" % (Settings.sitename, url_rule)
18
+    return formatted_rule
6
 
19
 
7
 
20
 
8
 def get_controller(request):
21
 def get_controller(request):
22
+
9
     url_rules = []
23
     url_rules = []
10
     for url in urls:
24
     for url in urls:
11
-        url_rules.append((url[0], url[1]))
25
+        url_rules.append((format_url_rule(url[0]), url[1]))
12
 
26
 
13
     # Returning the right controller to call
27
     # Returning the right controller to call
14
     for regex, callback in url_rules:
28
     for regex, callback in url_rules:

+ 2
- 2
plugins/webui/templates/errors/404.html View File

1
-{% extends "templates/base.html" %}
1
+{% extends "base.html" %}
2
 {% block title %}Error 404{% endblock %}
2
 {% block title %}Error 404{% endblock %}
3
 {% block content %}
3
 {% block content %}
4
-    <h1>404 - File Not Found</h1>
4
+    <h3>404 - File Not Found</h3>
5
 {% endblock %}
5
 {% endblock %}

Loading…
Cancel
Save