Pārlūkot izejas kodu

EmField: type attribute is now called fieldtype

ArnAud 9 gadus atpakaļ
vecāks
revīzija
9131f7bcd2
3 mainītis faili ar 15 papildinājumiem un 19 dzēšanām
  1. 0
    1
      EditorialModel/components.py
  2. 8
    11
      EditorialModel/model.py
  3. 7
    7
      EditorialModel/test/me.json

+ 0
- 1
EditorialModel/components.py Parādīt failu

@@ -83,7 +83,6 @@ class EmComponent(object):
83 83
                 attr[attr_f] = attr[attr_f].__str__()
84 84
         if isinstance(self, EditorialModel.fields.EmField):
85 85
             attr['component'] = 'EmField'
86
-            attr['type'] = self.fieldtype
87 86
         else:
88 87
             attr['component'] = self.__class__.__name__
89 88
         return attr

+ 8
- 11
EditorialModel/model.py Parādīt failu

@@ -53,6 +53,7 @@ class Model(object):
53 53
     ## Given a python class return a name
54 54
     # @param cls : The python class we want the name
55 55
     # @return A class name as string or False if cls is not an EmComponent child class
56
+    # @todo réécrire le split, c'est pas bô
56 57
     def name_from_emclass(em_class):
57 58
         if em_class not in Model.components_class:
58 59
             spl = em_class.__module__.split('.')
@@ -72,14 +73,12 @@ class Model(object):
72 73
             #Store and delete the EmComponent class name from datas
73 74
             cls_name = kwargs['component']
74 75
             del kwargs['component']
75
-            
76
+
76 77
             if cls_name == 'EmField':
77 78
                 #Special EmField process because of fieldtypes
78
-                if not 'type' in kwargs:
79
-                    raise AttributeError("Missing 'type' from EmField instanciation")
80
-                cls = EditorialModel.fields.EmField.get_field_class(kwargs['type'])
81
-                kwargs['fieldtype'] = kwargs['type']
82
-                del(kwargs['type'])
79
+                if not 'fieldtype' in kwargs:
80
+                    raise AttributeError("Missing 'fieldtype' from EmField instanciation")
81
+                cls = EditorialModel.fields.EmField.get_field_class(kwargs['fieldtype'])
83 82
             else:
84 83
                 cls = self.emclass_from_name(cls_name)
85 84
 
@@ -150,13 +149,11 @@ class Model(object):
150 149
     # @todo Handle a raise from the migration handler
151 150
     # @todo Transform the datas arg in **datas ?
152 151
     def create_component(self, component_type, datas, uid=None):
153
-        
154 152
         if component_type == 'EmField':
155 153
             #special process for EmField
156
-            if not 'type' in datas:
157
-                raise AttributeError("Missing 'type' from EmField instanciation")
158
-            em_obj = EditorialModel.fields.EmField.get_field_class(datas['type'])
159
-            del(datas['type'])
154
+            if not 'fieldtype' in datas:
155
+                raise AttributeError("Missing 'fieldtype' from EmField instanciation")
156
+            em_obj = EditorialModel.fields.EmField.get_field_class(datas['fieldtype'])
160 157
         else:
161 158
             em_obj = self.emclass_from_name(component_type)
162 159
 

+ 7
- 7
EditorialModel/test/me.json Parādīt failu

@@ -9,7 +9,7 @@
9 9
     "component":"EmFieldGroup", "name":"info", "string":"{\"fre\":\"Info\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "class_id":"1"
10 10
   },
11 11
   "4" : {
12
-    "component":"EmField", "name":"titre", "string":"{\"fre\":\"Titre\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "type":"char", "fieldgroup_id":"3", "rel_field_id":"", "optional":0, "internal":"", "icon":"0"
12
+    "component":"EmField", "name":"titre", "string":"{\"fre\":\"Titre\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "fieldtype":"char", "fieldgroup_id":"3", "rel_field_id":"", "optional":0, "internal":"", "icon":"0"
13 13
   },
14 14
   "5" : {
15 15
     "component":"EmType", "name":"article", "string":"{\"fre\":\"Article\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "class_id":"1", "icon":"0", "sortcolumn":"rank", "fields_list":[7], "superiors_list":{"parent":14}
@@ -18,22 +18,22 @@
18 18
     "component":"EmType", "name":"personne", "string":"{\"fre\":\"Personne\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "class_id":"2", "icon":"0", "sortcolumn":"rank", "fields_list":[10]
19 19
   },
20 20
   "7" : {
21
-    "component":"EmField", "name":"soustitre", "string":"{\"fre\":\"Sous-titre\"}", "help_text":"{}", "rank":"2", "date_update":"", "date_create":"", "type":"char", "fieldgroup_id":"3", "rel_field_id":"", "optional":1, "internal":"", "icon":"0"
21
+    "component":"EmField", "name":"soustitre", "string":"{\"fre\":\"Sous-titre\"}", "help_text":"{}", "rank":"2", "date_update":"", "date_create":"", "fieldtype":"char", "fieldgroup_id":"3", "rel_field_id":"", "optional":1, "internal":"", "icon":"0"
22 22
   },
23 23
   "8" : {
24 24
     "component":"EmFieldGroup", "name":"civilité", "string":"{\"fre\":\"Civilité\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "class_id":"2"
25 25
   },
26 26
   "9" : {
27
-    "component":"EmField", "name":"nom", "string":"{\"fre\":\"Nom\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "type":"char", "fieldgroup_id":"8", "rel_field_id":"", "optional":0, "internal":"", "icon":"0"
27
+    "component":"EmField", "name":"nom", "string":"{\"fre\":\"Nom\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "fieldtype":"char", "fieldgroup_id":"8", "rel_field_id":"", "optional":0, "internal":"", "icon":"0"
28 28
   },
29 29
   "10" : {
30
-    "component":"EmField", "name":"prenom", "string":"{\"fre\":\"Preom\"}", "help_text":"{}", "rank":"2", "date_update":"", "date_create":"", "type":"char", "fieldgroup_id":"8", "rel_field_id":"", "optional":1, "internal":"", "icon":"0"
30
+    "component":"EmField", "name":"prenom", "string":"{\"fre\":\"Preom\"}", "help_text":"{}", "rank":"2", "date_update":"", "date_create":"", "fieldtype":"char", "fieldgroup_id":"8", "rel_field_id":"", "optional":1, "internal":"", "icon":"0"
31 31
   },
32 32
   "11" : {
33
-    "component":"EmField", "name":"auteur", "string":"{\"fre\":\"Auteur\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "type":"rel2type", "fieldgroup_id":"17", "rel_to_type_id":"6", "rel_field_id":"", "optional":0, "internal":"", "icon":"0"
33
+    "component":"EmField", "name":"auteur", "string":"{\"fre\":\"Auteur\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "fieldtype":"rel2type", "fieldgroup_id":"17", "rel_to_type_id":"6", "rel_field_id":"", "optional":0, "internal":"", "icon":"0"
34 34
   },
35 35
   "12" : {
36
-    "component":"EmField", "name":"adresse", "string":"{\"fre\":\"Adresse\"}", "help_text":"{}", "rank":"2", "date_update":"", "date_create":"", "type":"char", "fieldgroup_id":"17", "rel_field_id":"11", "optional":0, "internal":"", "icon":"0"
36
+    "component":"EmField", "name":"adresse", "string":"{\"fre\":\"Adresse\"}", "help_text":"{}", "rank":"2", "date_update":"", "date_create":"", "fieldtype":"char", "fieldgroup_id":"17", "rel_field_id":"11", "optional":0, "internal":"", "icon":"0"
37 37
   },
38 38
   "13" : {
39 39
     "component":"EmClass", "name":"publication", "string":"{\"fre\":\"Publication\"}", "help_text":"{}", "rank":"2", "date_update":"", "date_create":"", "classtype":"entity", "icon":"0", "sortcolumn":"rank"
@@ -45,7 +45,7 @@
45 45
     "component":"EmFieldGroup", "name":"info", "string":"{\"fre\":\"Info\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "class_id":"13"
46 46
   },
47 47
   "16" : {
48
-    "component":"EmField", "name":"titre", "string":"{\"fre\":\"Titre\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "type":"char", "fieldgroup_id":"15", "rel_field_id":"", "optional":0, "internal":"", "icon":"0"
48
+    "component":"EmField", "name":"titre", "string":"{\"fre\":\"Titre\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "fieldtype":"char", "fieldgroup_id":"15", "rel_field_id":"", "optional":0, "internal":"", "icon":"0"
49 49
   },
50 50
   "17" : {
51 51
     "component":"EmFieldGroup", "name":"gens", "string":"{\"fre\":\"Gens\"}", "help_text":"{}", "rank":"2", "date_update":"", "date_create":"", "class_id":"1"

Notiek ielāde…
Atcelt
Saglabāt