Browse Source

Demo interface improvements

prieto 8 years ago
parent
commit
0b62e8151c

+ 7
- 0
lodel/auth/client.py View File

@@ -271,6 +271,13 @@ class Client(object, metaclass = ClientMetaclass):
271 271
     def is_anonymous(cls):
272 272
         return cls._assert_instance()
273 273
         #return Client._instance
274
+        
275
+    ##@brief Test wether a client is guest or logged in
276
+    #@return True if client is anonymous
277
+    #@ TODO : to be improved
278
+    @classmethod
279
+    def is_guest(cls):
280
+        return len(cls._instance.__session.datas) == 1
274 281
 
275 282
     ##@brief Method to call on authentication failure
276 283
     #@throw ClientAuthenticationFailure

+ 7
- 5
plugins/webui/interface/controllers/users.py View File

@@ -2,7 +2,7 @@
2 2
 from .base import get_response
3 3
 from ...exceptions import *
4 4
 from ...client import WebUiClient as WebUiClient
5
-from lodel.auth.client import LodelSession as Session
5
+
6 6
 from lodel import logger
7 7
 import leapi_dyncode as dyncode
8 8
 
@@ -10,13 +10,15 @@ def signin(request):
10 10
     msg=''
11 11
     if request.method == 'POST':
12 12
         WebUiClient.authenticate(request.form['inputLogin'], request.form['inputPassword'])
13
-        logger.debug(WebUiClient.session().datas)
14 13
         uid=WebUiClient.session().datas['__auth_user_infos']['uid']
15 14
         leoclass=WebUiClient.session().datas['__auth_user_infos']['leoclass']
16 15
         query_filter=list()
17
-        query_filter.append((leoclass.uid_fieldname()[0],' = ', uid))
18
-        username = leoclass.get(query_filter)
19
-        return get_response('users/welcome.html', username = username)
16
+        query_filter.append((leoclass.uid_fieldname()[0],'=', uid))
17
+        user = leoclass.get(query_filter)
18
+        return get_response('users/welcome.html', username = user[0].data('login'))
20 19
     else:
21 20
         return get_response('users/signin.html')
22 21
 
22
+def signout(request):
23
+    WebUiClient.destroy()
24
+    return get_response('users/signin.html')

+ 4
- 2
plugins/webui/interface/template/loader.py View File

@@ -3,12 +3,12 @@ import jinja2
3 3
 import os
4 4
 
5 5
 from lodel.settings import Settings
6
+from ...client import WebUiClient as WebUiClient
6 7
 import leapi_dyncode
7 8
 
8 9
 from .api import api_lodel_templates
9 10
 from .exceptions.not_allowed_custom_api_key_error import NotAllowedCustomAPIKeyError
10
-from ...main import root_url
11
-
11
+from ...main import root_url as root_url
12 12
 from ...main import PLUGIN_PATH
13 13
 TEMPLATE_PATH = os.path.realpath(os.path.join(PLUGIN_PATH, 'templates/'))
14 14
 
@@ -44,6 +44,8 @@ class TemplateLoader(object):
44 44
         template.globals['lodel'] = api_lodel_templates
45 45
         template.globals['leapi'] = leapi_dyncode
46 46
         template.globals['settings'] = Settings
47
+        template.globals['client'] = WebUiClient
48
+        template.globals['root_url'] = root_url()
47 49
         template.globals['url'] = lambda sufix='': root_url()\
48 50
             + ('' if sufix.startswith('/') else '/')\
49 51
             + sufix

+ 2
- 1
plugins/webui/interface/urls.py View File

@@ -15,5 +15,6 @@ urls = (
15 15
     (r'^/list_classes?$', list_classes),
16 16
     (r'^/show_object?$', show_object),
17 17
     (r'^/show_class?$', show_class),
18
-    (r'^/signin', signin)
18
+    (r'^/signin', signin),
19
+    (r'^/signout', signout)
19 20
 )

+ 4
- 1
plugins/webui/templates/admin/admin.html View File

@@ -1,7 +1,10 @@
1 1
 {% extends "base_backend.html" %}
2 2
 {% block title %}- Index{% endblock %}
3 3
 {% block body %}
4
-<h1>{{settings.sitename}} administration</h1>
4
+<ol class="breadcrumb">
5
+  <li class="active">Home</li>
6
+</ol>
7
+<h1 class="h1_lodel">{{settings.sitename}} administration</h1>
5 8
 <ul>
6 9
     <li><a href="admin/classes_admin">Edit object</a></li>
7 10
     <li><a href="admin/object_create">Create object</a></li>

+ 3
- 3
plugins/webui/templates/admin/admin_create.html View File

@@ -4,14 +4,14 @@
4 4
 {% block title %}- Creating a new {{target.__name__}}{% endblock %}
5 5
 {% block body %}
6 6
 <ol class="breadcrumb">
7
-  <li><a href="/lodel_i/admin">Home</a></li>
8
-  <li><a href="/lodel_i/admin/object_create">Creation</a></li>
7
+  <li><a href="/{{ root_url }}/admin">Home</a></li>
8
+  <li><a href="/{{ root_url }}/admin/object_create">Creation</a></li>
9 9
   <li class="active">Edit</li>
10 10
 </ol>
11 11
 {% if msg is not none %}
12 12
 {% block msg %} <p style="color:red; font-size:20pt; font-weight:bold">{{ msg }}</p> {% endblock %}
13 13
 {% endif %}
14
-<h1 style="padding-bottom:30px;">Creating a new {{target.__name__}}</h1>
14
+<h1  class="h1_lodel">Creating a new {{target.__name__}}</h1>
15 15
  <form class="form-horizontal" action="" method ="post">
16 16
      <input type="hidden" name="classname" id="classname" value="{{target.__name__}}" />
17 17
 	{% for fieldname, field in target.fields().items() %}

+ 4
- 4
plugins/webui/templates/admin/admin_edit.html View File

@@ -6,15 +6,15 @@
6 6
 {% block title %}Edit Object{% endblock %}
7 7
 {% block body %}
8 8
 <ol class="breadcrumb">
9
-  <li><a href="/lodel_i/admin">Home</a></li>
10
-  <li><a href="/lodel_i/admin/classes_admin">Edition</a></li>
11
-  <li><a href="/lodel_i/admin/class_admin?classname={{ target.__name__ }}">{{ target.__name__ }}</a></li>
9
+  <li><a href="/{{ root_url }}/admin">Home</a></li>
10
+  <li><a href="/{{ root_url }}/admin/classes_admin">Edition</a></li>
11
+  <li><a href="/{{ root_url }}/admin/class_admin?classname={{ target.__name__ }}">{{ target.__name__ }}</a></li>
12 12
   <li class="active">Edit</li>
13 13
 </ol>
14 14
 {% if msg is not none %}
15 15
 {% block msg %} <p style="color:red; font-size:20pt; font-weight:bold">{{ msg }}</p> {% endblock %}
16 16
 {% endif %}
17
-<h1 style="padding-bottom:30px;">Lodel 2 - Edit {{ target.__name__ }} with uid {{ lodel_id }} </h1>
17
+<h1  class="h1_lodel">Lodel 2 - Edit {{ target.__name__ }} with uid {{ lodel_id }} </h1>
18 18
     <form class="form-horizontal" action="" method ="post">
19 19
     <input type="hidden" name="uid" value="{{ lodel_id}}" />
20 20
     <input type="hidden" name="classname" value={{ target.__name__ }} />

+ 2
- 2
plugins/webui/templates/admin/list_classes_admin.html View File

@@ -2,10 +2,10 @@
2 2
 {% block title %}Lodel 2 - Admin - List of Classes{% endblock %}
3 3
 {% block body %} 
4 4
 <ol class="breadcrumb">
5
-  <li><a href="/lodel_i/admin">Home</a></li>
5
+  <li><a href="/{{ root_url }}/admin">Home</a></li>
6 6
   <li class="active">Edit</li>
7 7
 </ol>
8
-<h1>Edition</h1>
8
+<h1 class="h1_lodel">Edition</h1>
9 9
 <h2>Select a class</h2>
10 10
 <ul>
11 11
 {% for classe in my_classes %}

+ 3
- 3
plugins/webui/templates/admin/list_classes_create.html View File

@@ -2,10 +2,10 @@
2 2
 {% block title %}Lodel 2 - Admin - List of Classes{% endblock %}
3 3
 {% block body %}
4 4
 <ol class="breadcrumb">
5
-  <li><a href="/lodel_i/admin">Home</a></li>
5
+  <li><a href="/{{ root_url }}/admin">Home</a></li>
6 6
   <li class="active">Edit</li>
7 7
 </ol>
8
-<h1>Creation</h1>
8
+<h1 class="h1_lodel">Creation</h1>
9 9
 <h2>Choose a type to create an instance</h1>
10 10
 <ul>
11 11
 {% for classe in my_classes %}
@@ -16,6 +16,6 @@
16 16
     {% endfor %}
17 17
 </ul>
18 18
 <div>
19
-    <a href="../admin/">Return</a>
19
+    <a href="{{ root_url }}/admin/">Return</a>
20 20
 </div>
21 21
 {% endblock %}

+ 3
- 3
plugins/webui/templates/admin/show_class_admin.html View File

@@ -2,11 +2,11 @@
2 2
 {% block title %}Lodel 2 - Admin - Class {{ target.__name__ }} {% endblock %}
3 3
 {% block body %} 
4 4
 <ol class="breadcrumb">
5
-  <li><a href="/lodel_i/admin">Home</a></li>
6
-  <li><a href="/lodel_i/admin/classes_admin">Edition</a></li>
5
+  <li><a href="/{{ root_url }}/admin">Home</a></li>
6
+  <li><a href="/{{ root_url }}/admin/classes_admin">Edition</a></li>
7 7
   <li class="active">{{target.__name__  }}</li>
8 8
 </ol>
9
-<h1>Edition - {{target.__name__  }} </h1>
9
+<h1 class="h1_lodel">Edition - {{target.__name__  }} </h1>
10 10
 
11 11
  {% if not target.is_abstract() %}
12 12
     {% set objects = target.get(None) %}

+ 11
- 6
plugins/webui/templates/base.html View File

@@ -1,4 +1,6 @@
1 1
 <!doctype html>
2
+{% set not_connected = client.is_guest() %}
3
+
2 4
 <html lang="en">
3 5
 <head>
4 6
     <meta charset="UTF-8" />
@@ -24,18 +26,21 @@
24 26
             <span class="icon-bar"></span>
25 27
             <span class="icon-bar"></span>
26 28
           </button>
27
-          <a class="navbar-brand" href="#">Lodel 2</a>
29
+          <a class="navbar-brand" href="/{{ root_url }}/">Lodel 2</a>
28 30
         </div>
29 31
         <div id="navbar" class="navbar-collapse collapse">
30 32
           <ul class="nav navbar-nav">
31
-            <li class="active"><a href="/lodel_i/">Home</a></li>
33
+            <li class="active"><a href="/{{ root_url }}/">Home</a></li>
32 34
             <li><a href="list_classes">All types</a></li>
33 35
           </ul>
34 36
           <ul class="nav navbar-nav navbar-right">
35
-            <li id="backend-nav"><a href="/lodel_i/admin" class="btn btn-link disabled">Back-end</a></li>
36
-            <li id="backend-nav"><a href="/lodel_i/admin" class="btn btn-link">Back-end</a></li>
37
-              <li id="signin-nav"><a href="signin">Sign In</a></li>
38
-              <li id="signout-nav" style="display: none;"><a href="signout">Logout</a>
37
+             {% if not_connected %}
38
+                <li id="backend-nav"><a href="/{{ root_url }}/admin" class="btn btn-link disabled">Back-end</a></li>
39
+                <li id="signin-nav"><a href="signin">Sign In</a></li>
40
+             {% else %}
41
+                <li id="backend-nav"><a href="/{{ root_url }}/admin" class="btn btn-link">Back-end</a></li>
42
+                <li id="signout-nav"><a href="signout">Logout</a>
43
+              {% endif %}
39 44
           </ul>
40 45
         </div><!--/.nav-collapse -->
41 46
       </div>

+ 6
- 5
plugins/webui/templates/base_backend.html View File

@@ -25,13 +25,14 @@
25 25
         </div>
26 26
         <div id="navbar" class="navbar-collapse collapse">
27 27
           <ul class="nav navbar-nav">
28
-            <li class="active"><a href="/lodel_i/admin">Home</a></li>
29
-            <li><a href="/lodel_i/admin/object_create">Create</a></li>
30
-            <li><a href="/lodel_i/admin/classes_admin">Edit</a></li>
28
+            <li class="active"><a href="/{{ root_url }}/admin">Home</a></li>
29
+            <li><a href="/{{ root_url }}/admin/object_create">Create</a></li>
30
+            <li><a href="/{{ root_url }}/admin/classes_admin">Edit</a></li>
31 31
           </ul>
32 32
           <ul class="nav navbar-nav navbar-right">
33
-            <li><a href="/lodel_i/">Front-End</a></li>
34
-            <li id="signin-nav"><a href="/lodel_i/signin">Sign In</a></li>
33
+            <li><a href="/{{ root_url }}/">Front-End</a></li>
34
+            <li id="signout-nav"><a href="signout">Logout</a>
35
+            <li id="signin-nav"><a href="/{{ root_url }}/signin">Sign In</a></li>
35 36
           </ul>
36 37
         </div><!--/.nav-collapse -->
37 38
       </div>

+ 4
- 0
plugins/webui/templates/css/template.css View File

@@ -4,3 +4,7 @@ body {
4 4
   padding-left: 70px;
5 5
 } 
6 6
 
7
+h1{
8
+    padding-bottom : 30px;
9
+}
10
+

+ 5
- 1
plugins/webui/templates/listing/list_classes.html View File

@@ -1,7 +1,11 @@
1 1
 {% extends "base.html" %}
2 2
 {% block title %}Lodel 2 - List of Classes{% endblock %}
3 3
 {% block content %} 
4
-<h1>All types</h1>
4
+<ol class="breadcrumb">
5
+  <li><a href="/{{ root_url }}/">Home</a></li>
6
+  <li class="active">Types</li>
7
+</ol>
8
+<h1 class="h1_lodel">All types</h1>
5 9
 <ul>
6 10
 {% for classe in my_classes %}
7 11
     {% if classe.is_abstract() and allclasses == 1 %}

+ 3
- 3
plugins/webui/templates/listing/show_class.html View File

@@ -2,11 +2,11 @@
2 2
 {% block title %}Lodel 2 - Class {{ classname }} {% endblock %}
3 3
 {% block content %} 
4 4
 <ol class="breadcrumb">
5
-  <li><a href="/lodel_i/">Home</a></li>
6
-  <li><a href="/lodel_i/list_classes">Types</a></li>
5
+  <li><a href="/{{ root_url }}/">Home</a></li>
6
+  <li><a href="/{{ root_url }}/list_classes">Types</a></li>
7 7
   <li class="active">{{ classname }}</li>
8 8
 </ol>
9
-<h1>Type {{ classname }} </h1>
9
+<h1 class="h1_lodel">Type {{ classname }} </h1>
10 10
  {% set my_class  = leapi.name2class(classname) %}
11 11
  {% if my_class.child_classes()|length >0 %}
12 12
      <h2> Childs types</h2>

+ 4
- 5
plugins/webui/templates/listing/show_object.html View File

@@ -12,13 +12,12 @@
12 12
 {% import "components/components.html" as components %}
13 13
 {% block content %}
14 14
 <ol class="breadcrumb">
15
-  <li><a href="/lodel_i/">Home</a></li>
16
-  <li><a href="/lodel_i/list_classes">Types</a></li>
17
-  <li><a href="/lodel_i/show_class?classname={{ classname }}">{{ classname }}</a></li>
15
+  <li><a href="/{{ root_url }}/">Home</a></li>
16
+  <li><a href="/{{ root_url }}/list_classes">Types</a></li>
17
+  <li><a href="/{{ root_url }}/show_class?classname={{ classname }}">{{ classname }}</a></li>
18 18
   <li class="active">{{ lodel_id }}</li>
19 19
 </ol>
20
-<h1>Lodel 2 - {{ classname }} with uid {{ lodel_id }}</h1>
21
-    
20
+<h1 class="h1_lodel">Lodel 2 - {{ classname }} with uid {{ lodel_id }}</h1>
22 21
 <ul>
23 22
     <!-- To get a component HTML code, it is necessary to call : components.<macro_name>(args) -->
24 23
     {% for fieldname, fieldvalue in obj.fields(include_ro = True).items() %}

+ 1
- 1
plugins/webui/templates/users/signin.html View File

@@ -6,7 +6,7 @@
6 6
 {% endblock %}
7 7
 {% block content %} 
8 8
 <div class="container">
9
-    <h1>Lodel2 - Sign In</h1>
9
+    <h1 class="h1_lodel">Lodel2 - Sign In</h1>
10 10
 <form class="form-horizontal" method="POST" action="">
11 11
   <div class="form-group">
12 12
     <label for="inputLogin" class="col-sm-2 control-label">Login</label>

+ 5
- 3
plugins/webui/templates/users/welcome.html View File

@@ -1,5 +1,5 @@
1 1
 {% extends "base.html" %}
2
-{% block title %}Lodel 2 - Welcom{% endblock %}
2
+{% block title %}Lodel 2 - Welcome{% endblock %}
3 3
 <!-- Custom styles for this template -->
4 4
 {% block style %}
5 5
     <link href="http://127.0.0.1/css/signin.css" rel="stylesheet">
@@ -8,10 +8,12 @@
8 8
 <div class="container">
9 9
     <h1>Lodel2 - Welcome {{ username }}</h1>
10 10
     <div class="row">
11
-        <div class="col-md-6"></div>
12 11
         <div class="col-md-6">You are successfully login...</div>
13 12
     </div>
14
-    
13
+    <div class = "row" style="padding-top:20px;">
14
+        <a class="btn btn-default" href="/{{ root_url }}/signout" role="button">Logout</a>
15
+    </div>
16
+        
15 17
 
16 18
     </div> <!-- /container -->
17 19
 {% endblock %}

Loading…
Cancel
Save