瀏覽代碼

Default fields processing changes + updated the me.json

Now on load default fields for EmClass are created. The EmClass.check method create them if they are not present.
Yann Weber 9 年之前
父節點
當前提交
384ffb006b

+ 1
- 2
EditorialModel/backend/json_backend.py 查看文件

@@ -42,7 +42,6 @@ class EmBackendJson(EmBackendDummy):
42 42
         'rel_to_type_id': int_or_none,
43 43
         'rel_field_id': int_or_none,
44 44
         'optional': bool,
45
-        'internal': bool,
46 45
         'string': MlString.load,
47 46
         'help_text': MlString.load,
48 47
         'date_create': date_cast,
@@ -90,7 +89,7 @@ class EmBackendJson(EmBackendDummy):
90 89
     ## Saves the data in the data source json file
91 90
     # @param filename str : The filename to save the EM in (if None use self.json_file provided at init )
92 91
     def save(self, model, filename=None):
93
-        json_dump = json.dumps({component.uid: component.attr_flat() for component in model.components()}, default=self.date_handler)
92
+        json_dump = json.dumps({component.uid: component.attr_flat() for component in model.components()}, default=self.date_handler, indent=True)
94 93
         if self._json_file:
95 94
             with open(self._json_file if filename is None else filename, 'w') as json_file:
96 95
                 json_file.write(json_dump)

+ 14
- 3
EditorialModel/classes.py 查看文件

@@ -3,11 +3,9 @@
3 3
 ## @file classes.py
4 4
 # @see EditorialModel::classes::EmClass
5 5
 
6
+import EditorialModel
6 7
 from EditorialModel.components import EmComponent
7 8
 from EditorialModel.classtypes import EmClassType
8
-#from EditorialModel.exceptions import *
9
-#import EditorialModel.fieldtypes as ftypes
10
-import EditorialModel
11 9
 
12 10
 
13 11
 ## @brief Manipulate Classes of the Editorial Model
@@ -35,9 +33,22 @@ class EmClass(EmComponent):
35 33
         super(EmClass, self).__init__(model=model, uid=uid, name=name, string=string, help_text=help_text, date_update=date_update, date_create=date_create, rank=rank)
36 34
 
37 35
     ## Check if the EmComponent is valid
36
+    # @note this function add default and common fields to the EmClass if they are not yet created
38 37
     # @throw EmComponentCheckError if fails
39 38
     def check(self):
39
+        for fname in self.default_fields_list().keys():
40
+            if fname not in [f.name for f in self.fields()]:
41
+                self.model.add_default_class_fields(self.uid)
40 42
         super(EmClass, self).check()
43
+    
44
+    ## @brief Return the default fields list for this EmClass
45
+    # @return a dict with key = fieldname and value is a dict to pass to the EditorialModel::model::Model::creat_component() method
46
+    def default_fields_list(self):
47
+        ctype = EditorialModel.classtypes.EmClassType.get(self.classtype)
48
+        res = ctype['default_fields']
49
+        res.update(EditorialModel.classtypes.common_fields)
50
+        return res
51
+        
41 52
 
42 53
     ## @brief Delete a class if it's ''empty''
43 54
     # If a class has no fieldgroups delete it

+ 4
- 4
EditorialModel/classtypes.py 查看文件

@@ -4,20 +4,20 @@
4 4
 common_fields = {
5 5
     'lodel_id': {
6 6
         'fieldtype': 'pk',
7
-        'internal': 'object',
7
+        'internal': 'automatic',
8 8
     },
9 9
     'classid': {
10 10
         'fieldtype': 'integer',
11
-        'internal': 'object',
11
+        'internal': 'automatic',
12 12
     },
13 13
     'typeid': {
14 14
         'fieldtype': 'integer',
15
-        'internal': 'object',
15
+        'internal': 'automatic',
16 16
     },
17 17
     'string': {
18 18
         'fieldtype': 'char',
19 19
         'max_length': 128,
20
-        'internal': 'object',
20
+        'internal': 'automatic',
21 21
     },
22 22
 }
23 23
 

+ 5
- 1
EditorialModel/fields.py 查看文件

@@ -40,7 +40,7 @@ class EmField(EmComponent):
40 40
         if not internal:
41 41
             self.internal = False
42 42
         else:
43
-            if internal.lower() not in ['object', 'automatic']:
43
+            if internal.lower() not in ['automatic']:
44 44
                 raise ValueError("The internal arguments possible values are : [False, 'object', 'automatic']")
45 45
             self.internal = internal.lower()
46 46
 
@@ -57,6 +57,10 @@ class EmField(EmComponent):
57 57
         self.fieldtype = fieldtype
58 58
         self._fieldtype_args = kwargs
59 59
         self._fieldtype_args.update({'nullable' : nullable, 'uniq' : uniq})
60
+        #If internal is set, give it to the fieldtype
61
+        if self.internal:
62
+            self._fieldtype_args['internal'] = self.internal
63
+
60 64
         try:
61 65
             fieldtype_instance = self._fieldtype_cls(**self._fieldtype_args)
62 66
         except AttributeError as e:

+ 1
- 0
EditorialModel/fieldtypes/pk.py 查看文件

@@ -12,6 +12,7 @@ class EmFieldType(EditorialModel.fieldtypes.integer.EmFieldType):
12 12
             'default': None,
13 13
             'nullable': False,
14 14
             'uniq': False,
15
+            'internal': 'automatic',
15 16
         }
16 17
         # Checking args
17 18
         for name, value in kwargs.items():

+ 27
- 5
EditorialModel/model.py 查看文件

@@ -92,7 +92,8 @@ class Model(object):
92 92
             self.sort_components(component_class)
93 93
 
94 94
         #Check integrity
95
-        for uid, component in self._components['uids'].items():
95
+        loaded_comps = [(uid, component) for uid, component in self._components['uids'].items()]
96
+        for uid, component in loaded_comps:
96 97
             try:
97 98
                 component.check()
98 99
             except EmComponentCheckError as exception_object:
@@ -106,9 +107,14 @@ class Model(object):
106 107
         return self.backend.save(self, filename)
107 108
 
108 109
     ## Given a EmComponent child class return a list of instances
109
-    # @param cls EmComponent : A python class
110
+    # @param cls EmComponent|str : A python class
110 111
     # @return a list of instances or False if the class is not an EmComponent child
112
+    # @todo better implementation
111 113
     def components(self, cls=None):
114
+        if isinstance(cls, str):
115
+            cls = self.emclass_from_name(cls)
116
+            if not cls:
117
+                return False
112 118
         if cls is None:
113 119
             return [ self.component(uid) for uid in self._components['uids'] ]
114 120
         key_name = self.name_from_emclass(cls)
@@ -120,6 +126,24 @@ class Model(object):
120 126
     def component(self, uid):
121 127
         return False if uid not in self._components['uids'] else self._components['uids'][uid]
122 128
 
129
+    ## @brief Search in all the editorial model for a component with a specific name
130
+    # @param name str : the searched name
131
+    # @param comp_cls str|EmComponent : filter on component type (see components() method)
132
+    # @return a list of component with a specific name
133
+    def component_from_name(self, name, comp_cls = None):
134
+        if comp_cls == EmField or comp_cls == 'EmField':
135
+            res = list()
136
+            for field, fieldname in [ (f, f.name) for f in self.components('EmField')]:
137
+                if fieldname == name:
138
+                    res.append(field)
139
+            return res
140
+
141
+        for comp,compname in [ (c, c.name) for c in self.components(comp_cls)]:
142
+            if compname == name:
143
+                return comp
144
+
145
+        return False
146
+
123 147
     ## Sort components by rank in Model::_components
124 148
     # @param emclass pythonClass : The type of components to sort
125 149
     # @throw AttributeError if emclass is not valid
@@ -215,9 +239,7 @@ class Model(object):
215 239
                     fgid = fg.uid
216 240
                     break
217 241
 
218
-        ctype = EditorialModel.classtypes.EmClassType.get(emclass.classtype)
219
-        default_fields = ctype['default_fields']
220
-        default_fields.update(EditorialModel.classtypes.common_fields)
242
+        default_fields = emclass.default_fields_list()
221 243
         for fname, fdatas in default_fields.items():
222 244
             if not (fname in [ f.name for f in emclass.fields() ]):
223 245
                 #Adding the field

+ 545
- 62
EditorialModel/test/me.json 查看文件

@@ -1,65 +1,548 @@
1 1
 {
2
-  "1" : {
3
-    "component":"EmClass", "name":"textes", "string":"{\"fre\":\"Texte\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "classtype":"entity", "icon":"0", "sortcolumn":"rank"
2
+ "1": {
3
+  "date_update": "Fri Oct 16 11:05:04 2015",
4
+  "classtype": "entity",
5
+  "string": "{\"fre\": \"Texte\"}",
6
+  "icon": "0",
7
+  "help_text": "",
8
+  "name": "textes",
9
+  "date_create": "Fri Oct 16 11:05:04 2015",
10
+  "sortcolumn": "rank",
11
+  "component": "EmClass",
12
+  "rank": 1
13
+ },
14
+ "2": {
15
+  "date_update": "Fri Oct 16 11:05:04 2015",
16
+  "classtype": "person",
17
+  "string": "{\"fre\": \"Personnes\"}",
18
+  "icon": "0",
19
+  "help_text": "",
20
+  "name": "personnes",
21
+  "date_create": "Fri Oct 16 11:05:04 2015",
22
+  "sortcolumn": "rank",
23
+  "component": "EmClass",
24
+  "rank": 1
25
+ },
26
+ "3": {
27
+  "date_update": "Fri Oct 16 11:05:04 2015",
28
+  "string": "{\"fre\": \"Info\"}",
29
+  "class_id": 1,
30
+  "help_text": "",
31
+  "name": "info",
32
+  "date_create": "Fri Oct 16 11:05:04 2015",
33
+  "rank": 1,
34
+  "component": "EmFieldGroup"
35
+ },
36
+ "4": {
37
+  "date_update": "Fri Oct 16 11:05:04 2015",
38
+  "rel_field_id": null,
39
+  "optional": false,
40
+  "string": "{\"fre\": \"Titre\"}",
41
+  "icon": "0",
42
+  "help_text": "",
43
+  "date_create": "Fri Oct 16 11:05:04 2015",
44
+  "rank": 1,
45
+  "fieldgroup_id": 3,
46
+  "nullable": false,
47
+  "fieldtype": "char",
48
+  "uniq": false,
49
+  "name": "titre",
50
+  "internal": false,
51
+  "component": "EmField"
52
+ },
53
+ "5": {
54
+  "date_update": "Fri Oct 16 11:05:04 2015",
55
+  "string": "{\"fre\": \"Article\"}",
56
+  "icon": "0",
57
+  "help_text": "",
58
+  "date_create": "Fri Oct 16 11:05:04 2015",
59
+  "sortcolumn": "rank",
60
+  "fields_list": [
61
+   7
62
+  ],
63
+  "rank": 1,
64
+  "class_id": 1,
65
+  "superiors_list": {
66
+   "parent": [
67
+    14
68
+   ]
4 69
   },
5
-  "2" : {
6
-    "component":"EmClass", "name":"personnes", "string":"{\"fre\":\"Personnes\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "classtype":"person", "icon":"0", "sortcolumn":"rank"
70
+  "name": "article",
71
+  "component": "EmType"
72
+ },
73
+ "6": {
74
+  "date_update": "Fri Oct 16 11:05:04 2015",
75
+  "string": "{\"fre\": \"Personne\"}",
76
+  "icon": "0",
77
+  "help_text": "",
78
+  "date_create": "Fri Oct 16 11:05:04 2015",
79
+  "sortcolumn": "rank",
80
+  "fields_list": [
81
+   10
82
+  ],
83
+  "rank": 1,
84
+  "class_id": 2,
85
+  "superiors_list": {},
86
+  "name": "personne",
87
+  "component": "EmType"
88
+ },
89
+ "7": {
90
+  "date_update": "Fri Oct 16 11:05:04 2015",
91
+  "rel_field_id": null,
92
+  "optional": true,
93
+  "string": "{\"fre\": \"Sous-titre\"}",
94
+  "icon": "0",
95
+  "help_text": "",
96
+  "date_create": "Fri Oct 16 11:05:04 2015",
97
+  "rank": 2,
98
+  "fieldgroup_id": 3,
99
+  "nullable": false,
100
+  "fieldtype": "char",
101
+  "uniq": false,
102
+  "name": "soustitre",
103
+  "internal": false,
104
+  "component": "EmField"
105
+ },
106
+ "8": {
107
+  "date_update": "Fri Oct 16 11:05:04 2015",
108
+  "string": "{\"fre\": \"Civilit\\u00e9\"}",
109
+  "class_id": 2,
110
+  "help_text": "",
111
+  "name": "civilit\u00e9",
112
+  "date_create": "Fri Oct 16 11:05:04 2015",
113
+  "rank": 1,
114
+  "component": "EmFieldGroup"
115
+ },
116
+ "9": {
117
+  "date_update": "Fri Oct 16 11:05:04 2015",
118
+  "rel_field_id": null,
119
+  "optional": false,
120
+  "string": "{\"fre\": \"Nom\"}",
121
+  "icon": "0",
122
+  "help_text": "",
123
+  "date_create": "Fri Oct 16 11:05:04 2015",
124
+  "rank": 1,
125
+  "fieldgroup_id": 8,
126
+  "nullable": false,
127
+  "fieldtype": "char",
128
+  "uniq": false,
129
+  "name": "nom",
130
+  "internal": false,
131
+  "component": "EmField"
132
+ },
133
+ "10": {
134
+  "date_update": "Fri Oct 16 11:05:04 2015",
135
+  "rel_field_id": null,
136
+  "optional": true,
137
+  "string": "{\"fre\": \"Pr\\u00e9nom\"}",
138
+  "icon": "0",
139
+  "help_text": "",
140
+  "date_create": "Fri Oct 16 11:05:04 2015",
141
+  "rank": 2,
142
+  "fieldgroup_id": 8,
143
+  "nullable": false,
144
+  "fieldtype": "char",
145
+  "uniq": false,
146
+  "name": "prenom",
147
+  "internal": false,
148
+  "component": "EmField"
149
+ },
150
+ "11": {
151
+  "date_update": "Fri Oct 16 11:05:04 2015",
152
+  "rel_field_id": null,
153
+  "optional": false,
154
+  "string": "{\"fre\": \"Auteur\"}",
155
+  "icon": "0",
156
+  "help_text": "",
157
+  "date_create": "Fri Oct 16 11:05:04 2015",
158
+  "rank": 1,
159
+  "fieldgroup_id": 17,
160
+  "nullable": false,
161
+  "fieldtype": "rel2type",
162
+  "rel_to_type_id": 6,
163
+  "uniq": false,
164
+  "name": "auteur",
165
+  "internal": false,
166
+  "component": "EmField"
167
+ },
168
+ "12": {
169
+  "date_update": "Fri Oct 16 11:05:04 2015",
170
+  "rel_field_id": 11,
171
+  "optional": false,
172
+  "string": "{\"fre\": \"Adresse\"}",
173
+  "icon": "0",
174
+  "help_text": "",
175
+  "date_create": "Fri Oct 16 11:05:04 2015",
176
+  "rank": 2,
177
+  "fieldgroup_id": 17,
178
+  "nullable": false,
179
+  "fieldtype": "char",
180
+  "uniq": false,
181
+  "name": "adresse",
182
+  "internal": false,
183
+  "component": "EmField"
184
+ },
185
+ "13": {
186
+  "date_update": "Fri Oct 16 11:05:04 2015",
187
+  "classtype": "entity",
188
+  "string": "{\"fre\": \"Publication\"}",
189
+  "icon": "0",
190
+  "help_text": "",
191
+  "name": "publication",
192
+  "date_create": "Fri Oct 16 11:05:04 2015",
193
+  "sortcolumn": "rank",
194
+  "component": "EmClass",
195
+  "rank": 2
196
+ },
197
+ "14": {
198
+  "date_update": "Fri Oct 16 11:05:04 2015",
199
+  "string": "{\"fre\": \"Rubrique\"}",
200
+  "icon": "0",
201
+  "help_text": "",
202
+  "date_create": "Fri Oct 16 11:05:04 2015",
203
+  "sortcolumn": "rank",
204
+  "fields_list": [],
205
+  "rank": 1,
206
+  "class_id": 13,
207
+  "superiors_list": {
208
+   "parent": [
209
+    14,
210
+    19
211
+   ]
7 212
   },
8
-  "3" : {
9
-    "component":"EmFieldGroup", "name":"info", "string":"{\"fre\":\"Info\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "class_id":"1"
10
-  },
11
-  "4" : {
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
-  },
14
-  "5" : {
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]}
16
-  },
17
-  "6" : {
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
-  },
20
-  "7" : {
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
-  },
23
-  "8" : {
24
-    "component":"EmFieldGroup", "name":"civilité", "string":"{\"fre\":\"Civilité\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "class_id":"2"
25
-  },
26
-  "9" : {
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
-  },
29
-  "10" : {
30
-    "component":"EmField", "name":"prenom", "string":"{\"fre\":\"Prénom\"}", "help_text":"{}", "rank":"2", "date_update":"", "date_create":"", "fieldtype":"char", "fieldgroup_id":"8", "rel_field_id":"", "optional":1, "internal":"", "icon":"0"
31
-  },
32
-  "11" : {
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
-  },
35
-  "12" : {
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
-  },
38
-  "13" : {
39
-    "component":"EmClass", "name":"publication", "string":"{\"fre\":\"Publication\"}", "help_text":"{}", "rank":"2", "date_update":"", "date_create":"", "classtype":"entity", "icon":"0", "sortcolumn":"rank"
40
-  },
41
-  "14" : {
42
-    "component":"EmType", "name":"rubrique", "string":"{\"fre\":\"Rubrique\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "class_id":"13", "icon":"0", "sortcolumn":"rank", "superiors_list":{"parent":[14, 19]}
43
-  },
44
-  "15" : {
45
-    "component":"EmFieldGroup", "name":"info", "string":"{\"fre\":\"Info\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "class_id":"13"
46
-  },
47
-  "16" : {
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
-  },
50
-  "17" : {
51
-    "component":"EmFieldGroup", "name":"gens", "string":"{\"fre\":\"Gens\"}", "help_text":"{}", "rank":"2", "date_update":"", "date_create":"", "class_id":"1"
52
-  },
53
-  "18" : {
54
-    "component":"EmField", "name":"age", "string":"{\"fre\":\"Age\"}", "help_text":"{}", "rank":"3", "date_update":"", "date_create":"", "fieldtype":"char", "fieldgroup_id":"8", "rel_field_id":"", "optional":1, "internal":"", "icon":"0"
55
-  },
56
-  "19" : {
57
-    "component":"EmType", "name":"numero", "string":"{\"fre\":\"Numéro\"}", "help_text":"{}", "rank":"2", "date_update":"", "date_create":"", "class_id":"13", "icon":"0", "sortcolumn":"rank"
58
-  },
59
-  "20" : {
60
-    "component":"EmFieldGroup", "name":"couleurs", "string":"{\"fre\":\"Couleurs\"}", "help_text":"{}", "rank":"3", "date_update":"", "date_create":"", "class_id":"1"
61
-  },
62
-  "21" : {
63
-    "component":"EmField", "name":"bleu", "string":"{\"fre\":\"Bleu\"}", "help_text":"{}", "rank":"1", "date_update":"", "date_create":"", "fieldtype":"char", "fieldgroup_id":"20", "rel_field_id":"", "optional":1, "internal":"", "icon":"0"
64
-  }
65
-}
213
+  "name": "rubrique",
214
+  "component": "EmType"
215
+ },
216
+ "15": {
217
+  "date_update": "Fri Oct 16 11:05:04 2015",
218
+  "string": "{\"fre\": \"Info\"}",
219
+  "class_id": 13,
220
+  "help_text": "",
221
+  "name": "info",
222
+  "date_create": "Fri Oct 16 11:05:04 2015",
223
+  "rank": 1,
224
+  "component": "EmFieldGroup"
225
+ },
226
+ "16": {
227
+  "date_update": "Fri Oct 16 11:05:04 2015",
228
+  "rel_field_id": null,
229
+  "optional": false,
230
+  "string": "{\"fre\": \"Titre\"}",
231
+  "icon": "0",
232
+  "help_text": "",
233
+  "date_create": "Fri Oct 16 11:05:04 2015",
234
+  "rank": 1,
235
+  "fieldgroup_id": 15,
236
+  "nullable": false,
237
+  "fieldtype": "char",
238
+  "uniq": false,
239
+  "name": "titre",
240
+  "internal": false,
241
+  "component": "EmField"
242
+ },
243
+ "17": {
244
+  "date_update": "Fri Oct 16 11:05:04 2015",
245
+  "string": "{\"fre\": \"Gens\"}",
246
+  "class_id": 1,
247
+  "help_text": "",
248
+  "name": "gens",
249
+  "date_create": "Fri Oct 16 11:05:04 2015",
250
+  "rank": 2,
251
+  "component": "EmFieldGroup"
252
+ },
253
+ "18": {
254
+  "date_update": "Fri Oct 16 11:05:04 2015",
255
+  "rel_field_id": null,
256
+  "optional": true,
257
+  "string": "{\"fre\": \"Age\"}",
258
+  "icon": "0",
259
+  "help_text": "",
260
+  "date_create": "Fri Oct 16 11:05:04 2015",
261
+  "rank": 3,
262
+  "fieldgroup_id": 8,
263
+  "nullable": false,
264
+  "fieldtype": "char",
265
+  "uniq": false,
266
+  "name": "age",
267
+  "internal": false,
268
+  "component": "EmField"
269
+ },
270
+ "19": {
271
+  "date_update": "Fri Oct 16 11:05:04 2015",
272
+  "string": "{\"fre\": \"Num\\u00e9ro\"}",
273
+  "icon": "0",
274
+  "help_text": "",
275
+  "date_create": "Fri Oct 16 11:05:04 2015",
276
+  "sortcolumn": "rank",
277
+  "fields_list": [],
278
+  "rank": 2,
279
+  "class_id": 13,
280
+  "superiors_list": {},
281
+  "name": "numero",
282
+  "component": "EmType"
283
+ },
284
+ "20": {
285
+  "date_update": "Fri Oct 16 11:05:04 2015",
286
+  "string": "{\"fre\": \"Couleurs\"}",
287
+  "class_id": 1,
288
+  "help_text": "",
289
+  "name": "couleurs",
290
+  "date_create": "Fri Oct 16 11:05:04 2015",
291
+  "rank": 3,
292
+  "component": "EmFieldGroup"
293
+ },
294
+ "21": {
295
+  "date_update": "Fri Oct 16 11:05:04 2015",
296
+  "rel_field_id": null,
297
+  "optional": true,
298
+  "string": "{\"fre\": \"Bleu\"}",
299
+  "icon": "0",
300
+  "help_text": "",
301
+  "date_create": "Fri Oct 16 11:05:04 2015",
302
+  "rank": 1,
303
+  "fieldgroup_id": 20,
304
+  "nullable": false,
305
+  "fieldtype": "char",
306
+  "uniq": false,
307
+  "name": "bleu",
308
+  "internal": false,
309
+  "component": "EmField"
310
+ },
311
+ "22": {
312
+  "date_update": "Fri Oct 16 11:05:04 2015",
313
+  "string": "",
314
+  "class_id": 1,
315
+  "help_text": "",
316
+  "name": "_default",
317
+  "date_create": "Fri Oct 16 11:05:04 2015",
318
+  "rank": 4,
319
+  "component": "EmFieldGroup"
320
+ },
321
+ "23": {
322
+  "date_update": "Fri Oct 16 11:05:04 2015",
323
+  "rel_field_id": null,
324
+  "optional": false,
325
+  "string": "",
326
+  "icon": "0",
327
+  "help_text": "",
328
+  "date_create": "Fri Oct 16 11:05:04 2015",
329
+  "rank": 0,
330
+  "fieldgroup_id": 22,
331
+  "nullable": false,
332
+  "fieldtype": "integer",
333
+  "uniq": false,
334
+  "name": "classid",
335
+  "internal": "automatic",
336
+  "component": "EmField"
337
+ },
338
+ "24": {
339
+  "date_update": "Fri Oct 16 11:05:04 2015",
340
+  "rel_field_id": null,
341
+  "optional": false,
342
+  "string": "",
343
+  "icon": "0",
344
+  "help_text": "",
345
+  "date_create": "Fri Oct 16 11:05:04 2015",
346
+  "rank": 1,
347
+  "fieldgroup_id": 22,
348
+  "nullable": false,
349
+  "fieldtype": "char",
350
+  "max_length": 128,
351
+  "uniq": false,
352
+  "name": "string",
353
+  "internal": "automatic",
354
+  "component": "EmField"
355
+ },
356
+ "25": {
357
+  "date_update": "Fri Oct 16 11:05:04 2015",
358
+  "rel_field_id": null,
359
+  "optional": false,
360
+  "string": "",
361
+  "icon": "0",
362
+  "help_text": "",
363
+  "date_create": "Fri Oct 16 11:05:04 2015",
364
+  "rank": 2,
365
+  "fieldgroup_id": 22,
366
+  "nullable": false,
367
+  "fieldtype": "integer",
368
+  "uniq": false,
369
+  "name": "typeid",
370
+  "internal": "automatic",
371
+  "component": "EmField"
372
+ },
373
+ "26": {
374
+  "date_update": "Fri Oct 16 11:05:04 2015",
375
+  "rel_field_id": null,
376
+  "optional": false,
377
+  "string": "",
378
+  "icon": "0",
379
+  "help_text": "",
380
+  "date_create": "Fri Oct 16 11:05:04 2015",
381
+  "rank": 3,
382
+  "fieldgroup_id": 22,
383
+  "nullable": false,
384
+  "fieldtype": "pk",
385
+  "uniq": false,
386
+  "name": "lodel_id",
387
+  "internal": "automatic",
388
+  "component": "EmField"
389
+ },
390
+ "27": {
391
+  "date_update": "Fri Oct 16 11:05:04 2015",
392
+  "string": "",
393
+  "class_id": 2,
394
+  "help_text": "",
395
+  "name": "_default",
396
+  "date_create": "Fri Oct 16 11:05:04 2015",
397
+  "rank": 2,
398
+  "component": "EmFieldGroup"
399
+ },
400
+ "28": {
401
+  "date_update": "Fri Oct 16 11:05:04 2015",
402
+  "rel_field_id": null,
403
+  "optional": false,
404
+  "string": "",
405
+  "icon": "0",
406
+  "help_text": "",
407
+  "date_create": "Fri Oct 16 11:05:04 2015",
408
+  "rank": 0,
409
+  "fieldgroup_id": 27,
410
+  "nullable": false,
411
+  "fieldtype": "integer",
412
+  "uniq": false,
413
+  "name": "classid",
414
+  "internal": "automatic",
415
+  "component": "EmField"
416
+ },
417
+ "29": {
418
+  "date_update": "Fri Oct 16 11:05:04 2015",
419
+  "rel_field_id": null,
420
+  "optional": false,
421
+  "string": "",
422
+  "icon": "0",
423
+  "help_text": "",
424
+  "date_create": "Fri Oct 16 11:05:04 2015",
425
+  "rank": 1,
426
+  "fieldgroup_id": 27,
427
+  "nullable": false,
428
+  "fieldtype": "char",
429
+  "max_length": 128,
430
+  "uniq": false,
431
+  "name": "string",
432
+  "internal": "automatic",
433
+  "component": "EmField"
434
+ },
435
+ "30": {
436
+  "date_update": "Fri Oct 16 11:05:04 2015",
437
+  "rel_field_id": null,
438
+  "optional": false,
439
+  "string": "",
440
+  "icon": "0",
441
+  "help_text": "",
442
+  "date_create": "Fri Oct 16 11:05:04 2015",
443
+  "rank": 2,
444
+  "fieldgroup_id": 27,
445
+  "nullable": false,
446
+  "fieldtype": "integer",
447
+  "uniq": false,
448
+  "name": "typeid",
449
+  "internal": "automatic",
450
+  "component": "EmField"
451
+ },
452
+ "31": {
453
+  "date_update": "Fri Oct 16 11:05:04 2015",
454
+  "rel_field_id": null,
455
+  "optional": false,
456
+  "string": "",
457
+  "icon": "0",
458
+  "help_text": "",
459
+  "date_create": "Fri Oct 16 11:05:04 2015",
460
+  "rank": 3,
461
+  "fieldgroup_id": 27,
462
+  "nullable": false,
463
+  "fieldtype": "pk",
464
+  "uniq": false,
465
+  "name": "lodel_id",
466
+  "internal": "automatic",
467
+  "component": "EmField"
468
+ },
469
+ "32": {
470
+  "date_update": "Fri Oct 16 11:05:04 2015",
471
+  "string": "",
472
+  "class_id": 13,
473
+  "help_text": "",
474
+  "name": "_default",
475
+  "date_create": "Fri Oct 16 11:05:04 2015",
476
+  "rank": 2,
477
+  "component": "EmFieldGroup"
478
+ },
479
+ "33": {
480
+  "date_update": "Fri Oct 16 11:05:04 2015",
481
+  "rel_field_id": null,
482
+  "optional": false,
483
+  "string": "",
484
+  "icon": "0",
485
+  "help_text": "",
486
+  "date_create": "Fri Oct 16 11:05:04 2015",
487
+  "rank": 0,
488
+  "fieldgroup_id": 32,
489
+  "nullable": false,
490
+  "fieldtype": "integer",
491
+  "uniq": false,
492
+  "name": "classid",
493
+  "internal": "automatic",
494
+  "component": "EmField"
495
+ },
496
+ "34": {
497
+  "date_update": "Fri Oct 16 11:05:04 2015",
498
+  "rel_field_id": null,
499
+  "optional": false,
500
+  "string": "",
501
+  "icon": "0",
502
+  "help_text": "",
503
+  "date_create": "Fri Oct 16 11:05:04 2015",
504
+  "rank": 1,
505
+  "fieldgroup_id": 32,
506
+  "nullable": false,
507
+  "fieldtype": "char",
508
+  "max_length": 128,
509
+  "uniq": false,
510
+  "name": "string",
511
+  "internal": "automatic",
512
+  "component": "EmField"
513
+ },
514
+ "35": {
515
+  "date_update": "Fri Oct 16 11:05:04 2015",
516
+  "rel_field_id": null,
517
+  "optional": false,
518
+  "string": "",
519
+  "icon": "0",
520
+  "help_text": "",
521
+  "date_create": "Fri Oct 16 11:05:04 2015",
522
+  "rank": 2,
523
+  "fieldgroup_id": 32,
524
+  "nullable": false,
525
+  "fieldtype": "integer",
526
+  "uniq": false,
527
+  "name": "typeid",
528
+  "internal": "automatic",
529
+  "component": "EmField"
530
+ },
531
+ "36": {
532
+  "date_update": "Fri Oct 16 11:05:04 2015",
533
+  "rel_field_id": null,
534
+  "optional": false,
535
+  "string": "",
536
+  "icon": "0",
537
+  "help_text": "",
538
+  "date_create": "Fri Oct 16 11:05:04 2015",
539
+  "rank": 3,
540
+  "fieldgroup_id": 32,
541
+  "nullable": false,
542
+  "fieldtype": "pk",
543
+  "uniq": false,
544
+  "name": "lodel_id",
545
+  "internal": "automatic",
546
+  "component": "EmField"
547
+ }
548
+}

+ 0
- 3
EditorialModel/test/test_classes.py 查看文件

@@ -54,9 +54,6 @@ class TestEmClassCreation(ClassesTestCase):
54 54
         ClassesTestCase.setUpClass()
55 55
         test_class = EM_TEST_OBJECT.create_component(EmClass.__name__, {'name': 'testclass1', 'classtype': EmClassType.entity['name']})
56 56
 
57
-        #We check the uid
58
-        self.assertEqual(test_class.uid, 22)
59
-
60 57
         # We check that the class has been added in the right list in the model object
61 58
         class_components_records = EM_TEST_OBJECT.components(EmClass)
62 59
         self.assertIn(test_class, class_components_records)

Loading…
取消
儲存