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,21 +5,31 @@ from .template.loader import TemplateLoader
5 5
 
6 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 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 12
     response.status_code = status_code
13 13
     return response
14 14
 
15
+
15 16
 def admin(request):
16 17
     return get_response('admin/admin.html')
17 18
 
19
+
18 20
 def index(request):
19 21
     return get_response('index/index.html')
20 22
 
23
+
21 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 28
 def test(request):
25 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,12 +3,26 @@ import re
3 3
 
4 4
 from .controllers import *
5 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 21
 def get_controller(request):
22
+
9 23
     url_rules = []
10 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 27
     # Returning the right controller to call
14 28
     for regex, callback in url_rules:

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

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

Loading…
Cancel
Save