Browse Source

Demo interface improvements

prieto 8 years ago
parent
commit
0b62e8151c

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

271
     def is_anonymous(cls):
271
     def is_anonymous(cls):
272
         return cls._assert_instance()
272
         return cls._assert_instance()
273
         #return Client._instance
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
     ##@brief Method to call on authentication failure
282
     ##@brief Method to call on authentication failure
276
     #@throw ClientAuthenticationFailure
283
     #@throw ClientAuthenticationFailure

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

2
 from .base import get_response
2
 from .base import get_response
3
 from ...exceptions import *
3
 from ...exceptions import *
4
 from ...client import WebUiClient as WebUiClient
4
 from ...client import WebUiClient as WebUiClient
5
-from lodel.auth.client import LodelSession as Session
5
+
6
 from lodel import logger
6
 from lodel import logger
7
 import leapi_dyncode as dyncode
7
 import leapi_dyncode as dyncode
8
 
8
 
10
     msg=''
10
     msg=''
11
     if request.method == 'POST':
11
     if request.method == 'POST':
12
         WebUiClient.authenticate(request.form['inputLogin'], request.form['inputPassword'])
12
         WebUiClient.authenticate(request.form['inputLogin'], request.form['inputPassword'])
13
-        logger.debug(WebUiClient.session().datas)
14
         uid=WebUiClient.session().datas['__auth_user_infos']['uid']
13
         uid=WebUiClient.session().datas['__auth_user_infos']['uid']
15
         leoclass=WebUiClient.session().datas['__auth_user_infos']['leoclass']
14
         leoclass=WebUiClient.session().datas['__auth_user_infos']['leoclass']
16
         query_filter=list()
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
     else:
19
     else:
21
         return get_response('users/signin.html')
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
 import os
3
 import os
4
 
4
 
5
 from lodel.settings import Settings
5
 from lodel.settings import Settings
6
+from ...client import WebUiClient as WebUiClient
6
 import leapi_dyncode
7
 import leapi_dyncode
7
 
8
 
8
 from .api import api_lodel_templates
9
 from .api import api_lodel_templates
9
 from .exceptions.not_allowed_custom_api_key_error import NotAllowedCustomAPIKeyError
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
 from ...main import PLUGIN_PATH
12
 from ...main import PLUGIN_PATH
13
 TEMPLATE_PATH = os.path.realpath(os.path.join(PLUGIN_PATH, 'templates/'))
13
 TEMPLATE_PATH = os.path.realpath(os.path.join(PLUGIN_PATH, 'templates/'))
14
 
14
 
44
         template.globals['lodel'] = api_lodel_templates
44
         template.globals['lodel'] = api_lodel_templates
45
         template.globals['leapi'] = leapi_dyncode
45
         template.globals['leapi'] = leapi_dyncode
46
         template.globals['settings'] = Settings
46
         template.globals['settings'] = Settings
47
+        template.globals['client'] = WebUiClient
48
+        template.globals['root_url'] = root_url()
47
         template.globals['url'] = lambda sufix='': root_url()\
49
         template.globals['url'] = lambda sufix='': root_url()\
48
             + ('' if sufix.startswith('/') else '/')\
50
             + ('' if sufix.startswith('/') else '/')\
49
             + sufix
51
             + sufix

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

15
     (r'^/list_classes?$', list_classes),
15
     (r'^/list_classes?$', list_classes),
16
     (r'^/show_object?$', show_object),
16
     (r'^/show_object?$', show_object),
17
     (r'^/show_class?$', show_class),
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
 {% extends "base_backend.html" %}
1
 {% extends "base_backend.html" %}
2
 {% block title %}- Index{% endblock %}
2
 {% block title %}- Index{% endblock %}
3
 {% block body %}
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
 <ul>
8
 <ul>
6
     <li><a href="admin/classes_admin">Edit object</a></li>
9
     <li><a href="admin/classes_admin">Edit object</a></li>
7
     <li><a href="admin/object_create">Create object</a></li>
10
     <li><a href="admin/object_create">Create object</a></li>

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

4
 {% block title %}- Creating a new {{target.__name__}}{% endblock %}
4
 {% block title %}- Creating a new {{target.__name__}}{% endblock %}
5
 {% block body %}
5
 {% block body %}
6
 <ol class="breadcrumb">
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
   <li class="active">Edit</li>
9
   <li class="active">Edit</li>
10
 </ol>
10
 </ol>
11
 {% if msg is not none %}
11
 {% if msg is not none %}
12
 {% block msg %} <p style="color:red; font-size:20pt; font-weight:bold">{{ msg }}</p> {% endblock %}
12
 {% block msg %} <p style="color:red; font-size:20pt; font-weight:bold">{{ msg }}</p> {% endblock %}
13
 {% endif %}
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
  <form class="form-horizontal" action="" method ="post">
15
  <form class="form-horizontal" action="" method ="post">
16
      <input type="hidden" name="classname" id="classname" value="{{target.__name__}}" />
16
      <input type="hidden" name="classname" id="classname" value="{{target.__name__}}" />
17
 	{% for fieldname, field in target.fields().items() %}
17
 	{% for fieldname, field in target.fields().items() %}

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

6
 {% block title %}Edit Object{% endblock %}
6
 {% block title %}Edit Object{% endblock %}
7
 {% block body %}
7
 {% block body %}
8
 <ol class="breadcrumb">
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
   <li class="active">Edit</li>
12
   <li class="active">Edit</li>
13
 </ol>
13
 </ol>
14
 {% if msg is not none %}
14
 {% if msg is not none %}
15
 {% block msg %} <p style="color:red; font-size:20pt; font-weight:bold">{{ msg }}</p> {% endblock %}
15
 {% block msg %} <p style="color:red; font-size:20pt; font-weight:bold">{{ msg }}</p> {% endblock %}
16
 {% endif %}
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
     <form class="form-horizontal" action="" method ="post">
18
     <form class="form-horizontal" action="" method ="post">
19
     <input type="hidden" name="uid" value="{{ lodel_id}}" />
19
     <input type="hidden" name="uid" value="{{ lodel_id}}" />
20
     <input type="hidden" name="classname" value={{ target.__name__ }} />
20
     <input type="hidden" name="classname" value={{ target.__name__ }} />

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

2
 {% block title %}Lodel 2 - Admin - List of Classes{% endblock %}
2
 {% block title %}Lodel 2 - Admin - List of Classes{% endblock %}
3
 {% block body %} 
3
 {% block body %} 
4
 <ol class="breadcrumb">
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
   <li class="active">Edit</li>
6
   <li class="active">Edit</li>
7
 </ol>
7
 </ol>
8
-<h1>Edition</h1>
8
+<h1 class="h1_lodel">Edition</h1>
9
 <h2>Select a class</h2>
9
 <h2>Select a class</h2>
10
 <ul>
10
 <ul>
11
 {% for classe in my_classes %}
11
 {% for classe in my_classes %}

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

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

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

2
 {% block title %}Lodel 2 - Admin - Class {{ target.__name__ }} {% endblock %}
2
 {% block title %}Lodel 2 - Admin - Class {{ target.__name__ }} {% endblock %}
3
 {% block body %} 
3
 {% block body %} 
4
 <ol class="breadcrumb">
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
   <li class="active">{{target.__name__  }}</li>
7
   <li class="active">{{target.__name__  }}</li>
8
 </ol>
8
 </ol>
9
-<h1>Edition - {{target.__name__  }} </h1>
9
+<h1 class="h1_lodel">Edition - {{target.__name__  }} </h1>
10
 
10
 
11
  {% if not target.is_abstract() %}
11
  {% if not target.is_abstract() %}
12
     {% set objects = target.get(None) %}
12
     {% set objects = target.get(None) %}

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

1
 <!doctype html>
1
 <!doctype html>
2
+{% set not_connected = client.is_guest() %}
3
+
2
 <html lang="en">
4
 <html lang="en">
3
 <head>
5
 <head>
4
     <meta charset="UTF-8" />
6
     <meta charset="UTF-8" />
24
             <span class="icon-bar"></span>
26
             <span class="icon-bar"></span>
25
             <span class="icon-bar"></span>
27
             <span class="icon-bar"></span>
26
           </button>
28
           </button>
27
-          <a class="navbar-brand" href="#">Lodel 2</a>
29
+          <a class="navbar-brand" href="/{{ root_url }}/">Lodel 2</a>
28
         </div>
30
         </div>
29
         <div id="navbar" class="navbar-collapse collapse">
31
         <div id="navbar" class="navbar-collapse collapse">
30
           <ul class="nav navbar-nav">
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
             <li><a href="list_classes">All types</a></li>
34
             <li><a href="list_classes">All types</a></li>
33
           </ul>
35
           </ul>
34
           <ul class="nav navbar-nav navbar-right">
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
           </ul>
44
           </ul>
40
         </div><!--/.nav-collapse -->
45
         </div><!--/.nav-collapse -->
41
       </div>
46
       </div>

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

25
         </div>
25
         </div>
26
         <div id="navbar" class="navbar-collapse collapse">
26
         <div id="navbar" class="navbar-collapse collapse">
27
           <ul class="nav navbar-nav">
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
           </ul>
31
           </ul>
32
           <ul class="nav navbar-nav navbar-right">
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
           </ul>
36
           </ul>
36
         </div><!--/.nav-collapse -->
37
         </div><!--/.nav-collapse -->
37
       </div>
38
       </div>

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

4
   padding-left: 70px;
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
 {% extends "base.html" %}
1
 {% extends "base.html" %}
2
 {% block title %}Lodel 2 - List of Classes{% endblock %}
2
 {% block title %}Lodel 2 - List of Classes{% endblock %}
3
 {% block content %} 
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
 <ul>
9
 <ul>
6
 {% for classe in my_classes %}
10
 {% for classe in my_classes %}
7
     {% if classe.is_abstract() and allclasses == 1 %}
11
     {% if classe.is_abstract() and allclasses == 1 %}

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

2
 {% block title %}Lodel 2 - Class {{ classname }} {% endblock %}
2
 {% block title %}Lodel 2 - Class {{ classname }} {% endblock %}
3
 {% block content %} 
3
 {% block content %} 
4
 <ol class="breadcrumb">
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
   <li class="active">{{ classname }}</li>
7
   <li class="active">{{ classname }}</li>
8
 </ol>
8
 </ol>
9
-<h1>Type {{ classname }} </h1>
9
+<h1 class="h1_lodel">Type {{ classname }} </h1>
10
  {% set my_class  = leapi.name2class(classname) %}
10
  {% set my_class  = leapi.name2class(classname) %}
11
  {% if my_class.child_classes()|length >0 %}
11
  {% if my_class.child_classes()|length >0 %}
12
      <h2> Childs types</h2>
12
      <h2> Childs types</h2>

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

12
 {% import "components/components.html" as components %}
12
 {% import "components/components.html" as components %}
13
 {% block content %}
13
 {% block content %}
14
 <ol class="breadcrumb">
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
   <li class="active">{{ lodel_id }}</li>
18
   <li class="active">{{ lodel_id }}</li>
19
 </ol>
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
 <ul>
21
 <ul>
23
     <!-- To get a component HTML code, it is necessary to call : components.<macro_name>(args) -->
22
     <!-- To get a component HTML code, it is necessary to call : components.<macro_name>(args) -->
24
     {% for fieldname, fieldvalue in obj.fields(include_ro = True).items() %}
23
     {% for fieldname, fieldvalue in obj.fields(include_ro = True).items() %}

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

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

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

1
 {% extends "base.html" %}
1
 {% extends "base.html" %}
2
-{% block title %}Lodel 2 - Welcom{% endblock %}
2
+{% block title %}Lodel 2 - Welcome{% endblock %}
3
 <!-- Custom styles for this template -->
3
 <!-- Custom styles for this template -->
4
 {% block style %}
4
 {% block style %}
5
     <link href="http://127.0.0.1/css/signin.css" rel="stylesheet">
5
     <link href="http://127.0.0.1/css/signin.css" rel="stylesheet">
8
 <div class="container">
8
 <div class="container">
9
     <h1>Lodel2 - Welcome {{ username }}</h1>
9
     <h1>Lodel2 - Welcome {{ username }}</h1>
10
     <div class="row">
10
     <div class="row">
11
-        <div class="col-md-6"></div>
12
         <div class="col-md-6">You are successfully login...</div>
11
         <div class="col-md-6">You are successfully login...</div>
13
     </div>
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
     </div> <!-- /container -->
18
     </div> <!-- /container -->
17
 {% endblock %}
19
 {% endblock %}

Loading…
Cancel
Save