Browse Source

Start handling some back_ref constraints

Updated interface with nex dyncode
prieto 8 years ago
parent
commit
114148498b

+ 5
- 1
lodel/leapi/datahandlers/base_classes.py View File

29
 
29
 
30
     ##@brief List fields that will be exposed to the construct_data_method
30
     ##@brief List fields that will be exposed to the construct_data_method
31
     _construct_datas_deps = []
31
     _construct_datas_deps = []
32
-
32
+    
33
+    directly_editable = True
33
     ##@brief constructor
34
     ##@brief constructor
34
     # @param internal False | str : define whether or not a field is internal
35
     # @param internal False | str : define whether or not a field is internal
35
     # @param immutable bool : indicates if the fieldtype has to be defined in child classes of LeObject or if it is
36
     # @param immutable bool : indicates if the fieldtype has to be defined in child classes of LeObject or if it is
274
                 return None, FieldValidationError("Too many items")
275
                 return None, FieldValidationError("Too many items")
275
         return value, expt
276
         return value, expt
276
 
277
 
278
+    def check_data_consistency(self, emcomponent, fname, datas):
279
+        return True
280
+    
277
 ## @brief Class designed to handle datas access will fieldtypes are constructing datas
281
 ## @brief Class designed to handle datas access will fieldtypes are constructing datas
278
 #
282
 #
279
 # This class is designed to allow automatic scheduling of construct_data calls. 
283
 # This class is designed to allow automatic scheduling of construct_data calls. 

+ 1
- 1
lodel/leapi/datahandlers/references.py View File

130
 ##@brief This Reference class is designed to handler hierarchy with some constraint
130
 ##@brief This Reference class is designed to handler hierarchy with some constraint
131
 class Hierarch(MultipleRef):
131
 class Hierarch(MultipleRef):
132
     
132
     
133
+    directly_editable = False
133
     ##@brief Instanciate a data handler handling hierarchical relation with constraints
134
     ##@brief Instanciate a data handler handling hierarchical relation with constraints
134
     # @param back_reference tuple : Here it is mandatory to have a back ref (like a parent field)
135
     # @param back_reference tuple : Here it is mandatory to have a back ref (like a parent field)
135
     # @param max_depth int | None :  limit of depth
136
     # @param max_depth int | None :  limit of depth
170
                 else:
171
                 else:
171
                     raise ValueError("The items must be of the same type, string or %s" % (ecomponent.__name__))
172
                     raise ValueError("The items must be of the same type, string or %s" % (ecomponent.__name__))
172
             return l_value
173
             return l_value
173
-            logger.debug(l_value)
174
         else:
174
         else:
175
             return None
175
             return None

+ 5
- 2
plugins/webui/interface/controllers/listing.py View File

3
 import leapi_dyncode as dyncode
3
 import leapi_dyncode as dyncode
4
 
4
 
5
 def list_classes(request):
5
 def list_classes(request):
6
-    template_vars = {'my_classes': dyncode.dynclasses}
7
-    return get_response('listing/list_classes.html', my_classes=dyncode.dynclasses)
6
+    if 'allclasses' in request.GET:
7
+        allclasses = request.GET['allclasses']
8
+    else:
9
+        allclasses = 1
10
+    return get_response('listing/list_classes.html', my_classes=dyncode.dynclasses, allclasses = allclasses)
8
 
11
 
9
 def show_class(request):
12
 def show_class(request):
10
     if 'classname' in request.GET:
13
     if 'classname' in request.GET:

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

6
     (r'^/admin/?$', admin),
6
     (r'^/admin/?$', admin),
7
     (r'^/admin/create$', admin_create),
7
     (r'^/admin/create$', admin_create),
8
     (r'^/admin/update$', admin_update),
8
     (r'^/admin/update$', admin_update),
9
-    (r'^/admin/classes_admin$', admin_classes),
9
+    (r'^/admin/classes_admin', admin_classes),
10
     (r'^/admin/object_create', create_object),
10
     (r'^/admin/object_create', create_object),
11
     (r'^/admin/class_admin$', admin_class),
11
     (r'^/admin/class_admin$', admin_class),
12
     (r'/test/(?P<id>.*)$', test),
12
     (r'/test/(?P<id>.*)$', test),
13
     (r'^/test/?$', test),
13
     (r'^/test/?$', test),
14
     #(r'/show/(?P<id>.*)$', show_document),
14
     #(r'/show/(?P<id>.*)$', show_document),
15
     (r'^/list_classes', list_classes),
15
     (r'^/list_classes', list_classes),
16
+    (r'^/list_classes?$', list_classes),
16
     #(r'^/show_object/(.+)$', show_object),
17
     #(r'^/show_object/(.+)$', show_object),
17
     (r'^/show_object?$', show_object),
18
     (r'^/show_object?$', show_object),
18
     #(r'^/show_class/(.+)$', show_class),
19
     #(r'^/show_class/(.+)$', show_class),

+ 12
- 7
plugins/webui/templates/admin/editable_component.html View File

1
 {% macro input(fieldname, field, value='') -%}
1
 {% macro input(fieldname, field, value='') -%}
2
 	<label for="field_input_{{fieldname}}">{{fieldname}}</label>
2
 	<label for="field_input_{{fieldname}}">{{fieldname}}</label>
3
 	{% if field.base_type == 'bool' %}
3
 	{% if field.base_type == 'bool' %}
4
-		<input id="field_input_{{fieldname}}" name="field_input_{{fieldname}}" type="checkbox" checked="{% if value %}checked{% endif %}" />
4
+		<input id="field_input_{{fieldname}}" name="field_input_{{fieldname}}" type="checkbox" checked="{% if value %}checked{% endif %}" >
5
 	{% elif field.base_type == 'char' or field.base_type == 'int' %}
5
 	{% elif field.base_type == 'char' or field.base_type == 'int' %}
6
-		<input id="{{fieldname}}" name="field_input_{{fieldname}}" type="text" value="{{value}}" />
6
+		<input id="{{fieldname}}" name="field_input_{{fieldname}}" type="text" value="{{value}}" >
7
     {% elif field.base_type == 'ref' %}
7
     {% elif field.base_type == 'ref' %}
8
         {% if value is iterable %}
8
         {% if value is iterable %}
9
-        {% set sval=value|join(',') %}
9
+            {% set sval=value|join(',') %}
10
         {% else %}
10
         {% else %}
11
-        {% set sval = value %}
11
+            {% set sval = value %}
12
+        {% endif %}
13
+        {% if field.directly_editable %}
14
+            <input id="{{fieldname}}" name="field_input_{{fieldname}}" type="text" value="{{sval}}" >
15
+            {% set l_classe = field.allowed_classes %}
16
+            <p> Please enter uids to instances of {{ l_classe.__name__ }} separated by commas </p>
17
+        {% else %}
18
+            <input id="{{fieldname}}" name="field_input_{{fieldname}}" type="text" value="{{sval}}" readonly >
19
+            <p> If you want to update this field, please do it in child objects</p>
12
         {% endif %}
20
         {% endif %}
13
-        <input id="{{fieldname}}" name="field_input_{{fieldname}}" type="text" value="{{sval}}" />
14
-        {% set l_classe = field.allowed_classes %}
15
-        <p> Please enter uids to instances of {{ l_classe.__name__ }} separated by comma </p>
16
 	{% else %}
21
 	{% else %}
17
 		Unsupported base type "{{field.base_type}}" </br>
22
 		Unsupported base type "{{field.base_type}}" </br>
18
 	{% endif %}
23
 	{% endif %}

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

4
 <h1>Lodel 2 - List of Classes</h1>
4
 <h1>Lodel 2 - List of Classes</h1>
5
 <ul>
5
 <ul>
6
 {% for classe in my_classes %}
6
 {% for classe in my_classes %}
7
-    {% set abst = '' %}
8
-    {% if classe.is_abstract() %}
9
-    {% set abst = ' - Abstract class ' %}
10
-    {% else %}
11
-    {% set abst = ' - ' ~ classe.get(None)|length %}
12
-    {% endif %}
7
+    {% if classe.is_abstract() and allclasses == 1 %}
8
+        {% set abst = ' - Abstract class ' %}
9
+        <li> <a href="show_class?classname={{ classe.__name__ }}" target="_blank">{{ classe.__name__ }} </a>{{ abst }}</li>
10
+    {% elif not classe.is_abstract() %}
11
+        {% set abst = ' - ' ~ classe.get(None)|length %}
13
     <li> <a href="show_class?classname={{ classe.__name__ }}" target="_blank">{{ classe.__name__ }} </a>{{ abst }}</li>
12
     <li> <a href="show_class?classname={{ classe.__name__ }}" target="_blank">{{ classe.__name__ }} </a>{{ abst }}</li>
14
-    {% endfor %}
13
+    {% endif %}
14
+{% endfor %}
15
 </ul>
15
 </ul>
16
 {% endblock %}
16
 {% endblock %}

+ 1
- 1
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
 <h1>Lodel 2 - Class {{ classname }} </h1>
4
 <h1>Lodel 2 - Class {{ classname }} </h1>
5
- {% set my_class  = leapi.Object.name2class(classname) %}
5
+ {% set my_class  = leapi.name2class(classname) %}
6
  {% if my_class.child_classes()|length >0 %}
6
  {% if my_class.child_classes()|length >0 %}
7
      <h2> Childs classes</h2>
7
      <h2> Childs classes</h2>
8
      <ul>
8
      <ul>

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

1
 {% extends "base.html" %}
1
 {% extends "base.html" %}
2
 {% import 'components/components.html' as components %}
2
 {% import 'components/components.html' as components %}
3
-{% set my_class = leapi.Object.name2class(classname) %}
3
+{% set my_class = leapi.name2class(classname) %}
4
 {% set objects = my_class.get(('lodel_id = %s') % (lodel_id)) %}
4
 {% set objects = my_class.get(('lodel_id = %s') % (lodel_id)) %}
5
 {% set obj = objects.pop() %}
5
 {% set obj = objects.pop() %}
6
 {% if my_class.is_abstract() %}
6
 {% if my_class.is_abstract() %}

Loading…
Cancel
Save