Browse Source

Some bugfixes in datahandlers

prieto 8 years ago
parent
commit
a0d32cadb3

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

@@ -193,7 +193,8 @@ class Reference(DataHandler):
193 193
     # @param **kwargs : other arguments
194 194
     def __init__(self, allowed_classes = None, back_reference = None, internal=False, **kwargs):
195 195
         self.__allowed_classes = set() if allowed_classes is None else set(allowed_classes)
196
-        self._linked_classes = list() if allowed_classes is None else allowed_classes
196
+        self.allowed_classes = list() if allowed_classes is None else allowed_classes
197
+        
197 198
         if back_reference is not None:
198 199
             if len(back_reference) != 2:
199 200
                 raise ValueError("A tuple (classname, fieldname) expected but got '%s'" % back_reference)

+ 0
- 1
lodel/leapi/datahandlers/datas.py View File

@@ -66,7 +66,6 @@ class UniqID(Integer):
66 66
 
67 67
     help = 'Fieldtype designed to handle editorial model UID'
68 68
     base_type = 'int'
69
-    cast_type = int
70 69
 
71 70
     ##@brief A uid field
72 71
     # @param **kwargs

+ 1
- 0
lodel/leapi/datahandlers/datas_base.py View File

@@ -30,6 +30,7 @@ class Integer(DataField):
30 30
 
31 31
     help = 'Basic integer field'
32 32
     base_type = 'int'
33
+    cast_type = int
33 34
 
34 35
     def __init__(self, **kwargs):
35 36
         super().__init__( **kwargs)

+ 3
- 0
lodel/leapi/datahandlers/references.py View File

@@ -43,6 +43,7 @@ class List(MultipleRef):
43 43
         if isinstance(cur_value, str):
44 44
             value = cur_value.split(',')
45 45
             l_value = [uidtype.cast_type(uid) for uid in value]
46
+            #l_value = [int(uid) for uid in value]
46 47
 
47 48
             return l_value
48 49
         elif isinstance(cur_value, list):
@@ -89,6 +90,8 @@ class Set(MultipleRef):
89 90
         if isinstance(cur_value, str):
90 91
             value = cur_value.split(',')
91 92
             l_value = [uidtype.cast_type(uid) for uid in value] 
93
+            logger.debug("Valeur avec uidtype : %d" % l_value) 
94
+            #l_value = [int(uid) for uid in value] 
92 95
             return list(l_value)
93 96
         elif isinstance(cur_value, set):
94 97
             l_value = list()

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

@@ -15,6 +15,9 @@
15 15
      <p>&nbsp;</p>
16 16
  <input type="submit" value="Save">
17 17
  </form>
18
+<div>
19
+    <a href="object_create">Return</a>
20
+</div>
18 21
 {% endblock %}
19 22
 
20 23
 

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

@@ -17,4 +17,7 @@
17 17
     {% endfor %}
18 18
      <input type="submit" value="Save">
19 19
     </form>
20
+<div>
21
+    <a href="classes_admin">Return</a>
22
+</div>
20 23
 {% endblock %}

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

@@ -12,13 +12,13 @@
12 12
         {% endif %}
13 13
         {% if field.directly_editable %}
14 14
             <input id="{{fieldname}}" name="field_input_{{fieldname}}" type="text" value="{{sval}}" >
15
-            {% set l_classe = field._linked_classes %}
15
+            {% set l_classe = field.l_classes %}
16 16
             <p> Please enter uids to instances of {{ l_classe.__name__ }} separated by commas </p>
17 17
         {% else %}
18 18
             <input id="{{fieldname}}" name="field_input_{{fieldname}}" type="text" value="{{sval}}" readonly >
19 19
             <p> If you want to update this field, please do it in child objects</p>
20 20
         {% endif %}
21 21
 	{% else %}
22
-		Unsupported base type "{{field.base_type}}" </br>
22
+		Unsupported base type "{{field.base_type}}" <br>
23 23
 	{% endif %}
24 24
 {%- endmacro %}

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

@@ -11,4 +11,7 @@
11 11
     <li> <a href="class_admin?classname={{ classe.__name__ }}" target="_blank">{{ classe.__name__ }} </a>{{ abst }}</li>
12 12
     {% endfor %}
13 13
 </ul>
14
+<div>
15
+    <a href="../admin/">Return</a>
16
+</div>
14 17
 {% endblock %}

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

@@ -10,4 +10,7 @@
10 10
     {% endif %}
11 11
     {% endfor %}
12 12
 </ul>
13
+<div>
14
+    <a href="../admin/">Return</a>
15
+</div>
13 16
 {% endblock %}

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

@@ -14,15 +14,18 @@
14 14
     
15 15
 <ul>
16 16
     <!-- To get a component HTML code, it is necessary to call : components.<macro_name>(args) -->
17
-    {% for fieldname, fieldvalue in obj.fields().items() %}
17
+    {% for fieldname, fieldvalue in obj.fields(include_ro = True).items() %}
18 18
         {% if fieldvalue is not none %}
19 19
            {% if fieldvalue.base_type == 'ref' %}
20 20
                 {% if obj.data(fieldname) is iterable %}
21 21
                     <li>{{ fieldname }}
22
+                    {% set l_classe = fieldvalue.allowed_classes[0] %}
22 23
                         <ul>
23 24
                     {% for rel in obj.data(fieldname) %}
24
-                            {% set l_classe = fieldvalue.linked_classes %}
25
-                            <li><a href="show_object?classname={{ l_classe.__name__ }}&lodel_id={{ rel|int }}" target="_blank">{{ rel|int }}</a></li>
25
+                            <!-- Uid for linked_classes is casted to int....not good...but for a while.... -->
26
+                            {% set casttype = l_classe.data_handler(l_classe.uid_fieldname()[0]).cast_type %}
27
+                            {% set rel2 = casttype(rel) %}
28
+                            <li><a href="show_object?classname={{ l_classe.__name__ }}&lodel_id={{ rel2 }}" target="_blank">{{ rel2 }}</a></li>
26 29
                     {% endfor %}
27 30
                         </ul></li>
28 31
                 {% endif %}

Loading…
Cancel
Save