Browse Source

Fieldgroups are deleted

Yann Weber 9 years ago
parent
commit
10379c6a95

+ 5
- 17
EditorialModel/classes.py View File

18
 
18
 
19
     ranked_in = 'classtype'
19
     ranked_in = 'classtype'
20
     
20
     
21
-    ## @brief default fieldgroup name
22
-    default_fieldgroup = '_default'
23
-
24
     ## EmClass instanciation
21
     ## EmClass instanciation
25
     # @todo Classtype initialisation and test is not good EmClassType should give an answer or something like that
22
     # @todo Classtype initialisation and test is not good EmClassType should give an answer or something like that
26
     # @todo defines types check for icon and sortcolumn
23
     # @todo defines types check for icon and sortcolumn
60
         for emtype in self.model.components(EditorialModel.types.EmType):
57
         for emtype in self.model.components(EditorialModel.types.EmType):
61
             if emtype.class_id == self.uid:
58
             if emtype.class_id == self.uid:
62
                 return False
59
                 return False
63
-        for fieldgroup in self.model.components(EditorialModel.fieldgroups.EmFieldGroup):
64
-            if fieldgroup.name == self.default_fieldgroup:
65
-              #checking that the default fieldgroup contains only default fields
66
-              for fname in [f.name for f in fieldgroup.fields()]:
67
-                if fname not in EmClassType.get(self.classtype)['default_fields'].keys():
68
-                    return False
69
-            elif fieldgroup.class_id == self.uid and fieldgroup.name != self.default_fieldgroup:
70
-                return False
60
+        #If the class contains EmField that are not added by default, you cannot delete the EmClass
61
+        if len([f for f in self.fields() if f.name not in self.default_fields_list().keys()]) > 0:
62
+            return False
71
         return True
63
         return True
72
 
64
 
73
     ## Retrieve list of the field_groups of this class
65
     ## Retrieve list of the field_groups of this class
74
     # @return A list of fieldgroups instance
66
     # @return A list of fieldgroups instance
75
-    def fieldgroups(self):
67
+    def _fieldgroups(self):
76
         ret = []
68
         ret = []
77
         for fieldgroup in self.model.components(EditorialModel.fieldgroups.EmFieldGroup):
69
         for fieldgroup in self.model.components(EditorialModel.fieldgroups.EmFieldGroup):
78
             if fieldgroup.class_id == self.uid:
70
             if fieldgroup.class_id == self.uid:
82
     ## Retrieve list of fields
74
     ## Retrieve list of fields
83
     # @return fields [EmField]:
75
     # @return fields [EmField]:
84
     def fields(self, relational = True):
76
     def fields(self, relational = True):
85
-        fieldgroups = self.fieldgroups()
86
-        fields = []
87
-        for fieldgroup in fieldgroups:
88
-            fields += fieldgroup.fields(relational=relational)
89
-        return fields
77
+        return [ f for f in self.model.components('EmField') if f.class_id == self.uid ]
90
 
78
 
91
     ## Retrieve list of type of this class
79
     ## Retrieve list of type of this class
92
     # @return types [EditorialModel.types.EmType]:
80
     # @return types [EditorialModel.types.EmType]:

+ 1
- 1
EditorialModel/components.py View File

58
                 attributes_dump[attr_name] = attributes_dump[attr_name].uid
58
                 attributes_dump[attr_name] = attributes_dump[attr_name].uid
59
             elif isinstance(attributes_dump[attr_name], MlString):
59
             elif isinstance(attributes_dump[attr_name], MlString):
60
                 attributes_dump[attr_name] = attributes_dump[attr_name].__str__()
60
                 attributes_dump[attr_name] = attributes_dump[attr_name].__str__()
61
-        attributes_dump['component'] = 'EmField' if isinstance(self, EditorialModel.fields.EmField) else self.__class__.__name__
61
+        attributes_dump['component'] = self.__class__.__name__
62
 
62
 
63
         return attributes_dump
63
         return attributes_dump
64
 
64
 

+ 0
- 75
EditorialModel/fieldgroups.py View File

1
-#-*- coding: utf-8 -*-
2
-
3
-from EditorialModel.components import EmComponent
4
-from EditorialModel.fields import EmField
5
-from EditorialModel.classes import EmClass
6
-from EditorialModel.exceptions import EmComponentCheckError
7
-
8
-
9
-## Represents groups of EmField associated with an EmClass
10
-#
11
-# EmClass fields representation is organised with EmFieldGroup
12
-# @see EditorialModel::fields::EmField EditorialModel::classes::EmClass
13
-class EmFieldGroup(EmComponent):
14
-
15
-    ranked_in = 'class_id'
16
-
17
-    ## EmFieldGroup instanciation
18
-    def __init__(self, model, uid, name, class_id, string=None, help_text=None, date_update=None, date_create=None, rank=None):
19
-        self.class_id = class_id
20
-        self.check_type('class_id', int)
21
-        super(EmFieldGroup, self).__init__(model=model, uid=uid, name=name, string=string, help_text=help_text, date_update=date_update, date_create=date_create, rank=rank)
22
-
23
-    @property
24
-    def em_class(self):
25
-        return self.model.component(self.class_id)
26
-
27
-    ## Check if the EmFieldGroup is valid
28
-    # @throw EmComponentCheckError if fails
29
-    def check(self):
30
-        super(EmFieldGroup, self).check()
31
-        em_class = self.model.component(self.class_id)
32
-        if not em_class:
33
-            raise EmComponentCheckError("class_id contains a non existing uid '%s'" % str(self.class_id))
34
-        if not isinstance(em_class, EmClass):
35
-            raise EmComponentCheckError("class_id cointains an uid from a component that is not an EmClass but an %s" % type(em_class))
36
-
37
-    ## Deletes a fieldgroup
38
-    # @return True if the deletion is possible, False if not
39
-    def delete_check(self):
40
-        # all the EmField objects contained in this fieldgroup should be deleted first
41
-        fieldgroup_fields = self.fields()
42
-        if len(fieldgroup_fields) > 0:
43
-            raise NotEmptyError("This Fieldgroup still contains fields. It can't be deleted then")
44
-        return True
45
-
46
-    ## Get the list of associated fields
47
-    # if type_id, the fields will be filtered to represent selected fields of this EmType
48
-    # @param type_id int|None : if not None the fields will be filtered to represent selected fields of the EmType identified by this uid
49
-    # @param relational bool : If False don't returns the relational fields
50
-    # @return A list of EmField instance
51
-    def fields(self, type_id=None, relational=True):
52
-        if type_id is None:
53
-            fields = [field for field in self.model.components(EmField) if field.fieldgroup_id == self.uid]
54
-        else:
55
-            # for an EmType, fields have to be filtered
56
-            em_type = self.model.component(type_id)
57
-            fields = []
58
-            for field in self.model.components(EmField):
59
-                if field.fieldgroup_id != self.uid or (field.optional and field.uid not in em_type.fields_list):
60
-                    continue
61
-                # don't include relational field if parent should not be included
62
-                if field.rel_field_id:
63
-                    parent = self.model.component(field.rel_field_id)
64
-                    if parent.optional and parent.uid not in em_type.fields_list:
65
-                        continue
66
-                fields.append(field)
67
-        
68
-        if not relational:
69
-            fields = [ f for f in fields if f.rel_field_id is None and f.fieldtype != 'rel2type' ]
70
-
71
-        return fields
72
-
73
-
74
-class NotEmptyError(Exception):
75
-    pass

+ 8
- 6
EditorialModel/fields.py View File

16
 # Represents one data for a lodel2 document
16
 # Represents one data for a lodel2 document
17
 class EmField(EmComponent):
17
 class EmField(EmComponent):
18
 
18
 
19
-    ranked_in = 'fieldgroup_id'
19
+    ranked_in = 'class_id'
20
 
20
 
21
     ## Instanciate a new EmField
21
     ## Instanciate a new EmField
22
     # @todo define and test type for icon
22
     # @todo define and test type for icon
30
     # @param nullable bool : If True None values are allowed
30
     # @param nullable bool : If True None values are allowed
31
     # @param uniq bool : if True the value should be uniq in the db table
31
     # @param uniq bool : if True the value should be uniq in the db table
32
     # @param **kwargs : more keywords arguments for the fieldtype
32
     # @param **kwargs : more keywords arguments for the fieldtype
33
-    def __init__(self, model, uid, name, fieldgroup_id, fieldtype, optional=False, internal=False, rel_field_id=None, icon='0', string=None, help_text=None, date_update=None, date_create=None, rank=None, nullable=False, uniq=False, **kwargs):
33
+    def __init__(self, model, uid, name, class_id, fieldtype, optional=False, internal=False, rel_field_id=None, icon='0', string=None, help_text=None, date_update=None, date_create=None, rank=None, nullable=False, uniq=False, **kwargs):
34
 
34
 
35
-        self.fieldgroup_id = fieldgroup_id
36
-        self.check_type('fieldgroup_id', int)
35
+        self.class_id = class_id
36
+        self.check_type('class_id', int)
37
         self.optional = bool(optional)
37
         self.optional = bool(optional)
38
 
38
 
39
         if not internal:
39
         if not internal:
80
 
80
 
81
     ##@brief Return the EmFieldgroup this EmField belongs to
81
     ##@brief Return the EmFieldgroup this EmField belongs to
82
     @property
82
     @property
83
-    def fieldgroup(self):
83
+    def _fieldgroup(self):
84
         return self.model.component(self.fieldgroup_id)
84
         return self.model.component(self.fieldgroup_id)
85
     
85
     
86
     ## @brief Returns the EmClass this EmField belongs to
86
     ## @brief Returns the EmClass this EmField belongs to
87
     @property
87
     @property
88
     def em_class(self):
88
     def em_class(self):
89
-        return self.fieldgroup.em_class
89
+        return self.model.component(self.class_id)
90
 
90
 
91
     ## @brief Get the fieldtype instance
91
     ## @brief Get the fieldtype instance
92
     # @return a fieldtype instance
92
     # @return a fieldtype instance
111
     # @return True if valid False if not
111
     # @return True if valid False if not
112
     def check(self):
112
     def check(self):
113
         super(EmField, self).check()
113
         super(EmField, self).check()
114
+        """
114
         #Fieldgroup check
115
         #Fieldgroup check
115
         em_fieldgroup = self.model.component(self.fieldgroup_id)
116
         em_fieldgroup = self.model.component(self.fieldgroup_id)
116
         if not em_fieldgroup:
117
         if not em_fieldgroup:
117
             raise EmComponentCheckError("fieldgroup_id contains a non existing uid : '%d'" % self.fieldgroup_id)
118
             raise EmComponentCheckError("fieldgroup_id contains a non existing uid : '%d'" % self.fieldgroup_id)
118
         if not isinstance(em_fieldgroup, EditorialModel.fieldgroups.EmFieldGroup):
119
         if not isinstance(em_fieldgroup, EditorialModel.fieldgroups.EmFieldGroup):
119
             raise EmComponentCheckError("fieldgroup_id contains an uid from a component that is not an EmFieldGroup but a %s" % str(type(em_fieldgroup)))
120
             raise EmComponentCheckError("fieldgroup_id contains an uid from a component that is not an EmFieldGroup but a %s" % str(type(em_fieldgroup)))
121
+        """
120
         #Uniq Name check
122
         #Uniq Name check
121
         if len([ f for f in self.em_class.fields() if f.name == self.name]) > 1:
123
         if len([ f for f in self.em_class.fields() if f.name == self.name]) > 1:
122
             raise EmComponentCheckError("The field %d has a name '%s' that is not uniq in the EmClass %d"%(self.uid, self.name, self.em_class.uid))
124
             raise EmComponentCheckError("The field %d has a name '%s' that is not uniq in the EmClass %d"%(self.uid, self.name, self.em_class.uid))

+ 7
- 5
EditorialModel/model.py View File

7
 from EditorialModel.migrationhandler.dummy import DummyMigrationHandler
7
 from EditorialModel.migrationhandler.dummy import DummyMigrationHandler
8
 from EditorialModel.backend.dummy_backend import EmBackendDummy
8
 from EditorialModel.backend.dummy_backend import EmBackendDummy
9
 from EditorialModel.classes import EmClass
9
 from EditorialModel.classes import EmClass
10
-from EditorialModel.fieldgroups import EmFieldGroup
10
+#from EditorialModel.fieldgroups import EmFieldGroup
11
 from EditorialModel.fields import EmField
11
 from EditorialModel.fields import EmField
12
 from EditorialModel.types import EmType
12
 from EditorialModel.types import EmType
13
 from EditorialModel.exceptions import EmComponentCheckError, EmComponentNotExistError, MigrationHandlerChangeError
13
 from EditorialModel.exceptions import EmComponentCheckError, EmComponentNotExistError, MigrationHandlerChangeError
17
 ## @brief Manages the Editorial Model
17
 ## @brief Manages the Editorial Model
18
 class Model(object):
18
 class Model(object):
19
 
19
 
20
-    components_class = [EmClass, EmType, EmFieldGroup, EmField]
20
+    components_class = [EmClass, EmType, EmField]
21
 
21
 
22
     ## Constructor
22
     ## Constructor
23
     #
23
     #
33
         self.backend = None
33
         self.backend = None
34
         self.set_backend(backend)
34
         self.set_backend(backend)
35
 
35
 
36
-        self._components = {'uids': {}, 'EmClass': [], 'EmType': [], 'EmField': [], 'EmFieldGroup': []}
36
+        self._components = {'uids': {}, 'EmClass': [], 'EmType': [], 'EmField': []}
37
         self.load()
37
         self.load()
38
 
38
 
39
     def __hash__(self):
39
     def __hash__(self):
232
         emclass = self._components['uids'][class_uid]
232
         emclass = self._components['uids'][class_uid]
233
         if not isinstance(emclass, EditorialModel.classes.EmClass):
233
         if not isinstance(emclass, EditorialModel.classes.EmClass):
234
             raise ValueError("The uid '%d' is not an EmClass uid"%class_uid)
234
             raise ValueError("The uid '%d' is not an EmClass uid"%class_uid)
235
-
235
+        
236
+        """
236
         fgroup_name = EmClass.default_fieldgroup
237
         fgroup_name = EmClass.default_fieldgroup
237
 
238
 
238
         if fgroup_name not in [fg.name for fg in emclass.fieldgroups() ]:
239
         if fgroup_name not in [fg.name for fg in emclass.fieldgroups() ]:
245
                 if fg.name == fgroup_name:
246
                 if fg.name == fgroup_name:
246
                     fgid = fg.uid
247
                     fgid = fg.uid
247
                     break
248
                     break
249
+        """
248
 
250
 
249
         default_fields = emclass.default_fields_list()
251
         default_fields = emclass.default_fields_list()
250
         for fname, fdatas in default_fields.items():
252
         for fname, fdatas in default_fields.items():
251
             if not (fname in [ f.name for f in emclass.fields() ]):
253
             if not (fname in [ f.name for f in emclass.fields() ]):
252
                 #Adding the field
254
                 #Adding the field
253
                 fdatas['name'] = fname
255
                 fdatas['name'] = fname
254
-                fdatas['fieldgroup_id'] = fgid
256
+                fdatas['class_id'] = class_uid
255
                 self.create_component('EmField', fdatas)
257
                 self.create_component('EmField', fdatas)
256
         pass
258
         pass
257
 
259
 

+ 340
- 309
EditorialModel/test/me.json View File

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

+ 5
- 46
EditorialModel/test/test_classes.py View File

11
 import EditorialModel
11
 import EditorialModel
12
 from EditorialModel.classes import EmClass
12
 from EditorialModel.classes import EmClass
13
 from EditorialModel.classtypes import EmClassType
13
 from EditorialModel.classtypes import EmClassType
14
-from EditorialModel.fieldgroups import EmFieldGroup
15
 from EditorialModel.types import EmType
14
 from EditorialModel.types import EmType
16
 from EditorialModel.fields import EmField
15
 from EditorialModel.fields import EmField
17
 from EditorialModel.model import Model
16
 from EditorialModel.model import Model
74
         default_fields = ctype['default_fields']
73
         default_fields = ctype['default_fields']
75
         default_fields.update(EditorialModel.classtypes.common_fields)
74
         default_fields.update(EditorialModel.classtypes.common_fields)
76
         
75
         
77
-        fgs = test_class.fieldgroups()
78
-        self.assertEqual(len(fgs), 1, "Only one fieldgroup should be created when an EmClass is created")
79
-        self.assertEqual(fgs[0].name, EmClass.default_fieldgroup)
80
-        fnames = [ f.name for f in fgs[0].fields() ]
76
+        fnames = [ f.name for f in test_class.fields() ]
81
         self.assertEqual(sorted(fnames), sorted(list(default_fields.keys())))
77
         self.assertEqual(sorted(fnames), sorted(list(default_fields.keys())))
82
-            
83
 
78
 
84
 
79
 
85
 # Testing class deletion (and associated table drop)
80
 # Testing class deletion (and associated table drop)
105
     def test_table_refuse_delete(self):
100
     def test_table_refuse_delete(self):
106
         """ Test delete on an EmClass that has fieldgroup """
101
         """ Test delete on an EmClass that has fieldgroup """
107
         test_class = EM_TEST_OBJECT.create_component(EmClass.__name__, {'name': 'testfgclass1', 'classtype': EmClassType.entity['name']})
102
         test_class = EM_TEST_OBJECT.create_component(EmClass.__name__, {'name': 'testfgclass1', 'classtype': EmClassType.entity['name']})
108
-        fieldgroup = EM_TEST_OBJECT.create_component(EmFieldGroup.__name__, {'name': 'testsubfg1', 'class_id': test_class.uid})
109
-        self.assertFalse(EM_TEST_OBJECT.delete_component(test_class.uid), "delete method returns True but the class has fieldgroup(s)")
110
-
111
-        try:
112
-            EM_TEST_OBJECT.component(test_class.uid)
113
-        except Exception:
114
-            self.fail("The class has been deleted but it has fieldgroups")
115
 
103
 
116
         test_class = EM_TEST_OBJECT.create_component(EmClass.__name__, {'name': 'testClassFalseEmpty', 'classtype': EmClassType.entity['name']})
104
         test_class = EM_TEST_OBJECT.create_component(EmClass.__name__, {'name': 'testClassFalseEmpty', 'classtype': EmClassType.entity['name']})
117
-        foo_field = EM_TEST_OBJECT.create_component('EmField', {'name': 'ahah', 'fieldtype':'char', 'fieldgroup_id':test_class.fieldgroups()[0].uid})
118
-        self.assertFalse(EM_TEST_OBJECT.delete_component(test_class.uid), "delete method returns True but the class has a non-default field in the default fieldgroup")
105
+        foo_field = EM_TEST_OBJECT.create_component('EmField', {'name': 'ahah', 'fieldtype':'char', 'class_id':test_class.uid})
106
+        self.assertFalse(EM_TEST_OBJECT.delete_component(test_class.uid), "delete method returns True but the class has a non-default field")
119
 
107
 
120
         # TODO check : "table has been deleted but the class has fieldgroup"
108
         # TODO check : "table has been deleted but the class has fieldgroup"
121
 
109
 
125
             self.fail("The class has been deleted but it has non-default field in the default fieldgroup")
113
             self.fail("The class has been deleted but it has non-default field in the default fieldgroup")
126
 
114
 
127
 
115
 
128
-# Interface to fieldgroups
129
-class TestEmClassFieldgrousp(ClassesTestCase):
130
-
131
-    def setUp(self):
132
-        ClassesTestCase.setUpClass()
133
-        self.test_class = EM_TEST_OBJECT.create_component(EmClass.__name__, {'name': 'testClassFg', 'classtype': EmClassType.entity['name']})
134
-
135
-    # tests if fieldgroups() returns a list of EmFieldGroup
136
-    def test_fieldgroups(self):
137
-        """ Tests if fieldgroups method returns the right list of EmFieldGroup """
138
-        test_class = EM_TEST_OBJECT.component(self.test_class.uid)
139
-        EM_TEST_OBJECT.create_component(EmFieldGroup.__name__, {'name': 'testClassFg1', 'class_id': test_class.uid})
140
-        EM_TEST_OBJECT.create_component(EmFieldGroup.__name__, {'name': 'testClassFg2', 'class_id': test_class.uid})
141
-
142
-        fieldgroups = test_class.fieldgroups()
143
-        self.assertIsInstance(fieldgroups, list)
144
-        for fieldgroup in fieldgroups:
145
-            self.assertIsInstance(fieldgroup, EmFieldGroup)
146
-
147
-    # with no fieldgroups, fieldgroups() should return an empty list
148
-    def test_no_fieldgroups(self):
149
-        """ Test fieldgroups method on an 'empty' EmClass """
150
-        test_class = EM_TEST_OBJECT.create_component(EmClass.__name__, {'name': 'testClassFg3', 'classtype': EmClassType.entity['name']})
151
-        fieldgroups = test_class.fieldgroups()
152
-        self.assertEqual(len(fieldgroups), 1)
153
-        self.assertEqual(fieldgroups[0].name, EmClass.default_fieldgroup)
154
-
155
-
156
 # Interface to types
116
 # Interface to types
157
 class TestEmClassTypes(ClassesTestCase):
117
 class TestEmClassTypes(ClassesTestCase):
158
 
118
 
198
     def test_fields(self):
158
     def test_fields(self):
199
         """ testing fields method """
159
         """ testing fields method """
200
         test_class = EM_TEST_OBJECT.component(self.test_class.uid)
160
         test_class = EM_TEST_OBJECT.component(self.test_class.uid)
201
-        fg = EM_TEST_OBJECT.create_component(EmFieldGroup.__name__, {'name': 'testClassFieldsFg', 'class_id': test_class.uid})
202
-        EM_TEST_OBJECT.create_component(EmField.__name__, {'name': 'f1', 'fieldgroup_id': fg.uid, 'fieldtype': 'char'})
203
-        EM_TEST_OBJECT.create_component(EmField.__name__, {'name': 'f2', 'fieldgroup_id': fg.uid, 'fieldtype': 'char'})
161
+        EM_TEST_OBJECT.create_component(EmField.__name__, {'name': 'f1', 'class_id': test_class.uid, 'fieldtype': 'char'})
162
+        EM_TEST_OBJECT.create_component(EmField.__name__, {'name': 'f2', 'class_id': test_class.uid, 'fieldtype': 'char'})
204
         fields = test_class.fields()
163
         fields = test_class.fields()
205
         self.assertIsInstance(fields, list)
164
         self.assertIsInstance(fields, list)
206
         for field in fields:
165
         for field in fields:

+ 1
- 2
EditorialModel/test/test_component.py View File

4
 from EditorialModel.components import EmComponent
4
 from EditorialModel.components import EmComponent
5
 from EditorialModel.classes import EmClass
5
 from EditorialModel.classes import EmClass
6
 from EditorialModel.types import EmType
6
 from EditorialModel.types import EmType
7
-from EditorialModel.fieldgroups import EmFieldGroup
8
 from EditorialModel.fields import EmField
7
 from EditorialModel.fields import EmField
9
 
8
 
10
 from Lodel.utils.mlstring import MlString
9
 from Lodel.utils.mlstring import MlString
22
         me1 = Model(EmBackendJson('EditorialModel/test/me.json'))
21
         me1 = Model(EmBackendJson('EditorialModel/test/me.json'))
23
         me2 = Model(EmBackendJson('EditorialModel/test/me.json'), migration_handler=DummyMigrationHandler())
22
         me2 = Model(EmBackendJson('EditorialModel/test/me.json'), migration_handler=DummyMigrationHandler())
24
 
23
 
25
-        for comp_class in [EmClass, EmType, EmField, EmFieldGroup]:
24
+        for comp_class in [EmClass, EmType, EmField]:
26
             comp_l1 = me1.components(comp_class)
25
             comp_l1 = me1.components(comp_class)
27
             comp_l2 = me2.components(comp_class)
26
             comp_l2 = me2.components(comp_class)
28
 
27
 

+ 8
- 9
EditorialModel/test/test_field.py View File

35
 
35
 
36
     def setUp(self):
36
     def setUp(self):
37
         self.test_fieldtype = 'integer'
37
         self.test_fieldtype = 'integer'
38
-        self.test_fieldgroup = EM_TEST_OBJECT.component(3)
38
+        self.test_class = EM_TEST_OBJECT.components('EmClass')[0]
39
 
39
 
40
 
40
 
41
 ## TestField (Class)
41
 ## TestField (Class)
48
     # tests the creation process of a field
48
     # tests the creation process of a field
49
     def test_create(self):
49
     def test_create(self):
50
 
50
 
51
-        field = EM_TEST_OBJECT.create_component(EmField.__name__, {'name': 'testfield1', 'fieldgroup_id': self.test_fieldgroup.uid, 'fieldtype': self.test_fieldtype})
51
+        field = EM_TEST_OBJECT.create_component(EmField.__name__, {'name': 'testfield1', 'class_id': self.test_class.uid, 'fieldtype': self.test_fieldtype})
52
 
52
 
53
         # We check that the field has been added
53
         # We check that the field has been added
54
         field_records = EM_TEST_OBJECT.component(field.uid)
54
         field_records = EM_TEST_OBJECT.component(field.uid)
61
     def test_invalid_internal(self):
61
     def test_invalid_internal(self):
62
         """ Test that internal='object' is reserved for common_fields """
62
         """ Test that internal='object' is reserved for common_fields """
63
         with self.assertRaises(ValueError, msg="Only common_fields should be internal='object'"):
63
         with self.assertRaises(ValueError, msg="Only common_fields should be internal='object'"):
64
-            field = EM_TEST_OBJECT.create_component(EmField.__name__, {'name': 'testbadinternal','internal': 'object', 'fieldgroup_id': self.test_fieldgroup.uid, 'fieldtype': self.test_fieldtype})
64
+            field = EM_TEST_OBJECT.create_component(EmField.__name__, {'name': 'testbadinternal','internal': 'object', 'class_id': self.test_class.uid, 'fieldtype': self.test_fieldtype})
65
 
65
 
66
     def test_double_rel2type(self):
66
     def test_double_rel2type(self):
67
         """ Test the rel2type unicity """
67
         """ Test the rel2type unicity """
69
         emtype = em.components('EmType')[0]
69
         emtype = em.components('EmType')[0]
70
         emclass = [c for c in em.components('EmClass') if c != emtype.em_class][0]
70
         emclass = [c for c in em.components('EmClass') if c != emtype.em_class][0]
71
 
71
 
72
-        f1 = em.create_component('EmField', {'name': 'testr2t', 'fieldgroup_id': emclass.fieldgroups()[0].uid, 'fieldtype': 'rel2type', 'rel_to_type_id': emtype.uid})
72
+        f1 = em.create_component('EmField', {'name': 'testr2t', 'class_id': emclass.uid, 'fieldtype': 'rel2type', 'rel_to_type_id': emtype.uid})
73
 
73
 
74
         with self.assertRaises(EmComponentCheckError):
74
         with self.assertRaises(EmComponentCheckError):
75
-            f2 = em.create_component('EmField', {'name': 'testr2t2', 'fieldgroup_id': emclass.fieldgroups()[0].uid, 'fieldtype': 'rel2type', 'rel_to_type_id': emtype.uid})
75
+            f2 = em.create_component('EmField', {'name': 'testr2t2', 'class_id': emclass.uid, 'fieldtype': 'rel2type', 'rel_to_type_id': emtype.uid})
76
 
76
 
77
     def test_same_name(self):
77
     def test_same_name(self):
78
         """ Test the name unicity is the same EmClass"""
78
         """ Test the name unicity is the same EmClass"""
80
         emtype = em.components('EmType')[0]
80
         emtype = em.components('EmType')[0]
81
         emclass = [c for c in em.components('EmClass') if c != emtype.em_class][0]
81
         emclass = [c for c in em.components('EmClass') if c != emtype.em_class][0]
82
 
82
 
83
-        f1 = em.create_component('EmField', {'name': 'samename', 'fieldgroup_id': emclass.fieldgroups()[0].uid, 'fieldtype': 'char'})
83
+        f1 = em.create_component('EmField', {'name': 'samename', 'class_id': emclass.uid, 'fieldtype': 'char'})
84
 
84
 
85
         with self.assertRaises(EmComponentCheckError):
85
         with self.assertRaises(EmComponentCheckError):
86
-            f2 = em.create_component('EmField', {'name': 'samename', 'fieldgroup_id': emclass.fieldgroups()[1].uid, 'fieldtype': 'integer'} )
86
+            f2 = em.create_component('EmField', {'name': 'samename', 'class_id': emclass.uid, 'fieldtype': 'integer'} )
87
 
87
 
88
         
88
         
89
 
89
 
96
 
96
 
97
         # We create the two fields
97
         # We create the two fields
98
         for name in field_names:
98
         for name in field_names:
99
-            fields.append(EM_TEST_OBJECT.create_component(EmField.__name__, {'name': name, 'fieldgroup_id': self.test_fieldgroup.uid, 'fieldtype': self.test_fieldtype}))
99
+            fields.append(EM_TEST_OBJECT.create_component(EmField.__name__, {'name': name, 'class_id': self.test_class.uid, 'fieldtype': self.test_fieldtype}))
100
 
100
 
101
         for field in fields:
101
         for field in fields:
102
             # We check if the delete process was performed to the end
102
             # We check if the delete process was performed to the end
113
         """ Test if the EmField.em_class @property method is correct """
113
         """ Test if the EmField.em_class @property method is correct """
114
         for field in EM_TEST_OBJECT.components(EmField):
114
         for field in EM_TEST_OBJECT.components(EmField):
115
             self.assertIn(field, field.em_class.fields())
115
             self.assertIn(field, field.em_class.fields())
116
-            self.assertIn(field.fieldgroup, field.em_class.fieldgroups())

+ 0
- 192
EditorialModel/test/test_fieldgroups.py View File

1
-import os
2
-import logging
3
-
4
-from unittest import TestCase
5
-
6
-from EditorialModel.fieldgroups import EmFieldGroup
7
-from EditorialModel.classes import EmClass
8
-from EditorialModel.types import EmType
9
-from EditorialModel.fields import EmField
10
-from Lodel.utils.mlstring import MlString
11
-from EditorialModel.model import Model
12
-from EditorialModel.backend.json_backend import EmBackendJson
13
-
14
-#=###########=#
15
-# TESTS SETUP #
16
-#=###########=#
17
-
18
-TEST_FIELDGROUP_DBNAME = 'test_em_fieldgroup_db.sqlite'
19
-
20
-EM_TEST = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'me.json')
21
-EM_TEST_OBJECT = None
22
-
23
-
24
-def setUpModule():
25
-    global EM_TEST_OBJECT
26
-    EM_TEST_OBJECT = Model(EmBackendJson(EM_TEST))
27
-
28
-    logging.basicConfig(level=logging.CRITICAL)
29
-
30
-
31
-def tearDownModule():
32
-    pass
33
-
34
-
35
-class FieldGroupTestCase(TestCase):
36
-
37
-    def setUp(self):
38
-        pass
39
-
40
-
41
-#======================#
42
-# EmFielgroup.__init__ #
43
-#======================#
44
-class TestInit(FieldGroupTestCase):
45
-
46
-    def setUp(self):
47
-        super(TestInit, self).setUp()
48
-        self.tfgs = [
49
-            {"name": "testfg1", "string": MlString({"fre": "Gens"}), "help_text": MlString({}), "class_id": 1},
50
-            {"name": "testfg2", "string": MlString({"fre": "Gens"}), "help_text": MlString({}), "class_id": 1},
51
-            {"name": "testfg3", "string": MlString({"fre": "Civilité"}), "help_text": MlString({}), "class_id": 2}
52
-        ]
53
-        for tfg in self.tfgs:
54
-            fieldgroup = EM_TEST_OBJECT.create_component(EmFieldGroup.__name__, tfg)
55
-
56
-    def test_init(self):
57
-        """ Test that EmFieldgroup are correctly instanciated compare to self.tfg """
58
-        for tfg in self.tfgs:
59
-            fieldgroup = EM_TEST_OBJECT.component(tfg['uid'])
60
-            for attr in tfg:
61
-                if attr != 'uid':
62
-                    v = tfg[attr]
63
-                    self.assertEqual(getattr(fieldgroup, attr), v, "The '" + attr + "' property fetched from backend doesn't match the excepted value")
64
-
65
-    def test_init_badargs(self):
66
-        """ Tests that EmFieldGroup init fails when bad arguments are given"""
67
-        baduid = self.tfgs[2]['uid'] + 4096
68
-        badname = 'NonExistingName'
69
-
70
-        # TODO Voir si on garde le return False de Model.component() ou si on utilise plutôt une exception EmComponentNotExistError en modifiant le reste du code source pour gérer ce cas
71
-        self.assertFalse(EM_TEST_OBJECT.component(baduid), msg="Should be False because fieldgroup with id " + str(baduid) + " should not exist")
72
-        self.assertFalse(EM_TEST_OBJECT.component(badname), msg="Should be False because fieldgroup with id " + str(badname) + " should not exist")
73
-        self.assertFalse(EM_TEST_OBJECT.component(print), msg="Should be False when a function name is given as argument")
74
-        with self.assertRaises(TypeError, msg="Should raise when crazy arguments are given"):
75
-            fieldgroup = EM_TEST_OBJECT.component(['hello', 'world'])
76
-
77
-
78
-#=====================#
79
-# EmFieldgroup.create #
80
-#=====================#
81
-class TestCreate(FieldGroupTestCase):
82
-
83
-    def test_create(self):
84
-        """Does create actually create a fieldgroup ?"""
85
-        params = {
86
-            'EmClass entity instance': EM_TEST_OBJECT.component(1),
87
-            'EmClass entry instance': EM_TEST_OBJECT.component(2)
88
-        }
89
-
90
-        for i, param_name in enumerate(params):
91
-            arg = params[param_name]
92
-            if isinstance(arg, EmClass):
93
-                cl = arg
94
-            else:
95
-                cl = EM_TEST_OBJECT.component(arg)
96
-
97
-            fieldgroup_name = 'new_fg' + str(i)
98
-            fieldgroup = EM_TEST_OBJECT.create_component(EmFieldGroup.__name__, {'name': fieldgroup_name, 'class_id': arg.uid})
99
-            self.assertEqual(fieldgroup.name, fieldgroup_name, "Model.create_component() doesn't instanciate name correctly")
100
-            self.assertEqual(fieldgroup.class_id, cl.uid, "Model.create_component() doesn't instanciate class_id correctly")
101
-
102
-            nfg = EM_TEST_OBJECT.component(fieldgroup.uid)
103
-
104
-            # Checking object property
105
-            for fname in fieldgroup.__dict__:
106
-                self.assertEqual(getattr(nfg, fname), getattr(fieldgroup, fname), "Msg inconsistency when a created fieldgroup is fetched from the backend (in " + fname + " property)")
107
-
108
-    def test_create_badargs(self):
109
-        """ Does create fails when badargs given ? """
110
-        badargs = {
111
-            'EmClass type (not an instance)': EmClass,
112
-            'Non Existing id': 9000,
113
-            'Another component instance': EM_TEST_OBJECT.create_component(EmType.__name__, {'name': 'fooType', 'class_id': EM_TEST_OBJECT.component(1).uid}),
114
-            'A function': print
115
-        }
116
-
117
-        for i, badarg_name in enumerate(badargs):
118
-            with self.assertRaises(TypeError, msg="Should raise because trying to give " + badarg_name + " an em_class object as value"):
119
-                fieldgroup = EM_TEST_OBJECT.create_component(EmFieldGroup.__name__, {'name': 'new_fg' + i, 'class_id': badargs[badarg_name].uid})
120
-
121
-        # Creating a fieldgroup to test duplicate name
122
-        exfg = EM_TEST_OBJECT.create_component(EmFieldGroup.__name__, {'name': 'existingfg', 'class_id': EM_TEST_OBJECT.component(1).uid})
123
-        badargs = {
124
-            'an integer': (42, AttributeError),
125
-            'a function': (print, AttributeError),
126
-            'an EmClass': (EM_TEST_OBJECT.component(2), AttributeError)
127
-        }
128
-        for badarg_name in badargs:
129
-            (badarg, expt) = badargs[badarg_name]
130
-            with self.assertRaises(expt, msg="Should raise because trying to give " + badarg_name + " as first argument"):
131
-                fieldgroup = EM_TEST_OBJECT.create_component(EmFieldGroup.__name__, {'name': badarg, 'class_id': EM_TEST_OBJECT.component(1).uid})
132
-
133
-
134
-#=====================#
135
-# EmFieldgroup.fields #
136
-#=====================#
137
-class TestFields(FieldGroupTestCase):
138
-
139
-    def setUp(self):
140
-        super(TestFields, self).setUp()
141
-        self.fg1 = EM_TEST_OBJECT.create_component(EmFieldGroup.__name__, {'name': 'testfg1', 'class_id': EM_TEST_OBJECT.component(1).uid})
142
-        self.fg2 = EM_TEST_OBJECT.create_component(EmFieldGroup.__name__, {'name': 'testfg2', 'class_id': EM_TEST_OBJECT.component(2).uid})
143
-        self.fg3 = EM_TEST_OBJECT.create_component(EmFieldGroup.__name__, {'name': 'testfg3', 'class_id': EM_TEST_OBJECT.component(1).uid})
144
-
145
-    def test_fields(self):
146
-        """ Does it returns actually associated fields ? """
147
-        # Creating fields
148
-        test_fields1 = [
149
-            {'name': 'field1', 'fieldgroup_id': self.fg1.uid, 'fieldtype': 'integer'},
150
-            {'name': 'field2', 'fieldgroup_id': self.fg1.uid, 'fieldtype': 'integer'},
151
-            {'name': 'field4', 'fieldgroup_id': self.fg1.uid, 'fieldtype': 'integer'}
152
-        ]
153
-
154
-        test_fields2 = [
155
-            {'name': 'field3', 'fieldgroup_id': self.fg2.uid, 'fieldtype': 'integer'}
156
-        ]
157
-
158
-        expected1 = []
159
-
160
-        for finfo in test_fields1:
161
-            field = EM_TEST_OBJECT.create_component(EmField.__name__, finfo)
162
-            expected1.append(field.uid)
163
-
164
-        for finfo in test_fields2:
165
-            field = EM_TEST_OBJECT.create_component(EmField.__name__, finfo)
166
-
167
-        expected1 = set(expected1)
168
-
169
-        tests = {
170
-            'newly': EM_TEST_OBJECT.component(self.fg1.uid),
171
-            'old': self.fg1
172
-        }
173
-
174
-        for name in tests:
175
-            fieldgroup = tests[name]
176
-            flist = fieldgroup.fields()
177
-            res = []
178
-            for field in flist:
179
-                res.append(field.uid)
180
-            self.assertEqual(set(res), set(expected1))
181
-
182
-    def test_non_relational(self):
183
-        """ Check that relationnal=False returns only non relational fields """
184
-        for fgrp in [ self.fg1, self.fg2, self.fg3 ]:
185
-            for field in fgrp.fields(relational=False):
186
-                self.assertTrue(field.fieldtype != 'rel2type' and field.rel_field_id is None)
187
-
188
-    def test_empty_fields(self):
189
-        """ Testing fields method on an empty fieldgroup """
190
-        fieldgroup = self.fg3
191
-        fields_list = fieldgroup.fields()
192
-        self.assertEqual(len(fields_list), 0)

+ 4
- 12
EditorialModel/test/test_model.py View File

4
 from EditorialModel.model import Model
4
 from EditorialModel.model import Model
5
 from EditorialModel.classes import EmClass
5
 from EditorialModel.classes import EmClass
6
 from EditorialModel.types import EmType
6
 from EditorialModel.types import EmType
7
-from EditorialModel.fieldgroups import EmFieldGroup
8
 from EditorialModel.fields import EmField
7
 from EditorialModel.fields import EmField
9
 from EditorialModel.components import EmComponent
8
 from EditorialModel.components import EmComponent
10
 from Lodel.utils.mlstring import MlString
9
 from Lodel.utils.mlstring import MlString
40
     def test_components(self):
39
     def test_components(self):
41
         """ Test components fetching """
40
         """ Test components fetching """
42
         uid_l = list()
41
         uid_l = list()
43
-        for comp_class in [EmClass, EmType, EmField, EmFieldGroup]:
42
+        for comp_class in [EmClass, EmType, EmField]:
44
             comp_l = self.ed_mod.components(comp_class)
43
             comp_l = self.ed_mod.components(comp_class)
45
             #Testing types of returned components
44
             #Testing types of returned components
46
             for component in comp_l:
45
             for component in comp_l:
139
                     'fields_list': [],
138
                     'fields_list': [],
140
                 }
139
                 }
141
             },
140
             },
142
-            'EmFieldGroup': {
143
-                'cls': EmFieldGroup,
144
-                'cdats': {
145
-                    'name': 'FooFG',
146
-                    'class_id': self.ed_mod.components(EmClass)[0].uid,
147
-                },
148
-            },
149
             'EmField': {
141
             'EmField': {
150
                 'cls': EmField,
142
                 'cls': EmField,
151
                 'cdats': {
143
                 'cdats': {
152
                     'name': 'FooField',
144
                     'name': 'FooField',
153
-                    'fieldgroup_id': self.ed_mod.components(EmFieldGroup)[0].uid,
145
+                    'class_id': self.ed_mod.components(EmClass)[0].uid,
154
                     'fieldtype': 'char',
146
                     'fieldtype': 'char',
155
                     'max_length': 64,
147
                     'max_length': 64,
156
                     'optional': True,
148
                     'optional': True,
305
 
297
 
306
     def test_compclass_getter(self):
298
     def test_compclass_getter(self):
307
         """ Test the Model methods that handles name <-> EmComponent conversion """
299
         """ Test the Model methods that handles name <-> EmComponent conversion """
308
-        for classname in ['EmField', 'EmClass', 'EmFieldGroup', 'EmType']:
300
+        for classname in ['EmField', 'EmClass', 'EmType']:
309
             cls = Model.emclass_from_name(classname)
301
             cls = Model.emclass_from_name(classname)
310
             self.assertNotEqual(cls, False, "emclass_from_name return False when '%s' given as parameter" % classname)
302
             self.assertNotEqual(cls, False, "emclass_from_name return False when '%s' given as parameter" % classname)
311
             self.assertEqual(cls.__name__, classname)
303
             self.assertEqual(cls.__name__, classname)
313
         for classname in ['EmComponent', 'EmFoobar', int, EmClass]:
305
         for classname in ['EmComponent', 'EmFoobar', int, EmClass]:
314
             self.assertFalse(Model.emclass_from_name(classname))
306
             self.assertFalse(Model.emclass_from_name(classname))
315
 
307
 
316
-        for comp_cls in [EmClass, EmFieldGroup, EmType]:
308
+        for comp_cls in [EmClass, EmField, EmType]:
317
             self.assertEqual(Model.name_from_emclass(comp_cls), comp_cls.__name__)
309
             self.assertEqual(Model.name_from_emclass(comp_cls), comp_cls.__name__)
318
         for comp in self.ed_mod.components(EmField):
310
         for comp in self.ed_mod.components(EmField):
319
             self.assertEqual(Model.name_from_emclass(comp.__class__), 'EmField')
311
             self.assertEqual(Model.name_from_emclass(comp.__class__), 'EmField')

+ 0
- 16
EditorialModel/test/test_types.py View File

97
         self.article.del_superior(self.numero, EmNature.PARENT)
97
         self.article.del_superior(self.numero, EmNature.PARENT)
98
 
98
 
99
 
99
 
100
-class TestTypesMisc(TypeTestCase):
101
-
102
-    def test_fieldgroups(self):
103
-
104
-        # should not send empty fieldgroups
105
-        self.assertNotIn(self.couleur_group, self.article.fieldgroups())
106
-
107
-        # add a field, fieldgroup should now appear
108
-        self.article.select_field(self.couleur_field)
109
-        self.assertIn(self.couleur_group, self.article.fieldgroups())
110
-
111
-        # delete it, fieldgroup should disappear
112
-        self.article.unselect_field(self.couleur_field)
113
-        self.assertNotIn(self.couleur_group, self.article.fieldgroups())
114
-
115
-
116
 class TestDeleteTypes(TypeTestCase):
100
 class TestDeleteTypes(TypeTestCase):
117
 
101
 
118
     def test_delete_types(self):
102
     def test_delete_types(self):

+ 4
- 5
EditorialModel/types.py View File

89
 
89
 
90
     ## Get the list of non empty associated fieldgroups
90
     ## Get the list of non empty associated fieldgroups
91
     # @return A list of EmFieldGroup instance
91
     # @return A list of EmFieldGroup instance
92
-    def fieldgroups(self):
92
+    def _fieldgroups(self):
93
         fieldgroups = [fieldgroup for fieldgroup in self.em_class.fieldgroups() if len(fieldgroup.fields(self.uid))]
93
         fieldgroups = [fieldgroup for fieldgroup in self.em_class.fieldgroups() if len(fieldgroup.fields(self.uid))]
94
         return fieldgroups
94
         return fieldgroups
95
 
95
 
102
     ## Return the list of associated fields
102
     ## Return the list of associated fields
103
     # @return A list of EmField instance
103
     # @return A list of EmField instance
104
     def fields(self, relational = False):
104
     def fields(self, relational = False):
105
-        fields = [field for fieldgroup in self.fieldgroups() for field in fieldgroup.fields(self.uid)]
106
-        if not relational:
107
-            fields = [ f for f in fields if f.rel_field_id is None and f.fieldtype != 'rel2type' ]
108
-        return fields
105
+        return [ field for field in self.em_class.fields() if not field.optional or (field.optional and field.uid in self.fields_list) ]
109
 
106
 
110
     ## Select_field (Function)
107
     ## Select_field (Function)
111
     #
108
     #
323
                 raise EmComponentCheckError("The element %d of selected_field is not an EmField but a %s" % (i, str(type(field))))
320
                 raise EmComponentCheckError("The element %d of selected_field is not an EmField but a %s" % (i, str(type(field))))
324
             if not field.optional:
321
             if not field.optional:
325
                 raise EmComponentCheckError("The element %d of selected_field is an EmField not optional" % i)
322
                 raise EmComponentCheckError("The element %d of selected_field is an EmField not optional" % i)
323
+            """
326
             if field.fieldgroup_id not in [fg.uid for fg in self.fieldgroups()]:
324
             if field.fieldgroup_id not in [fg.uid for fg in self.fieldgroups()]:
327
                 raise EmComponentCheckError("The element %d of selected_field is an EmField that is part of an EmFieldGroup that is not associated with this EmType" % i)
325
                 raise EmComponentCheckError("The element %d of selected_field is an EmField that is part of an EmFieldGroup that is not associated with this EmType" % i)
326
+            """
328
 
327
 
329
         for nature, superiors_uid in self.superiors_list.items():
328
         for nature, superiors_uid in self.superiors_list.items():
330
             for superior_uid in superiors_uid:
329
             for superior_uid in superiors_uid:

+ 40
- 0
leobject/datasources/ledatasourcesql.py View File

200
                 prepared_filters[prepared_filter_key] = prepared_filter_value
200
                 prepared_filters[prepared_filter_key] = prepared_filter_value
201
 
201
 
202
         return prepared_filters
202
         return prepared_filters
203
+
204
+    ## @brief Link two object given a relation nature, depth and rank
205
+    # @param lesup LeObject : a LeObject
206
+    # @param lesub LeObject : a LeObject
207
+    # @param nature str|None : The relation nature or None if rel2type
208
+    # @param rank int : a rank
209
+    def add_relation(self, lesup, lesub, nature=None, depth=None, rank=None, **rel_attr):
210
+        if len(rel_attr) > 0 and not (nature is None):
211
+            #not a rel2type but have some relation attribute
212
+            raise AttributeError("No relation attributes allowed for non rel2type relations")
213
+
214
+        with self.connection() as cur:
215
+            sql = insert(RELATIONS_TABLE_NAME, {'id_sup':lesup.lodel_id, 'id_sub':lesub.lodel_id, 'nature':nature,'rank':rank, 'depth':depth})
216
+            if cur.execute(sql) != 1:
217
+                raise RuntimeError("Unknow SQL error")
218
+
219
+            if len(rel_attr) > 0:
220
+                #a relation table exists
221
+                cur.execute('SELECT last_insert_id()')
222
+                relation_id, = cur.fetchone()
223
+                raise NotImplementedError()
224
+
225
+
226
+        return True
227
+            
228
+
229
+    ## @brief Delete a link between two objects given a relation nature
230
+    # @param lesup LeObject : a LeObject
231
+    # @param lesub LeObject : a LeObject
232
+    # @param nature str|None : The relation nature
233
+    def del_relation(self, lesup, lesub, nature=None):
234
+        raise NotImplementedError()
235
+    
236
+    ## @brief Return all relation of a lodel_id given a position and a nature
237
+    # @param lodel_id int : We want the relations of this lodel_id
238
+    # @param superior bool : If true search the relations where lodel_id is in id_sup
239
+    # @param nature str|None : Search for relations with the given nature (if None rel2type)
240
+    # @param return an array of dict with keys [ id_sup, id_sub, rank, depth, nature ]
241
+    def get_relations(self, lodel_id, superior=True, nature=None):
242
+        raise NotImplementedError()

+ 0
- 9
leobject/lefactory.py View File

75
         for field in emclass.fields(relational = False):
75
         for field in emclass.fields(relational = False):
76
             cls_fields[field.name] = LeFactory.fieldtype_construct_from_field(field)
76
             cls_fields[field.name] = LeFactory.fieldtype_construct_from_field(field)
77
             fti = field.fieldtype_instance()
77
             fti = field.fieldtype_instance()
78
-        
79
-        # Populating fieldgroup attr
80
-        cls_fieldgroup = dict()
81
-        for fieldgroup in emclass.fieldgroups():
82
-            cls_fieldgroup[fieldgroup.name] = list()
83
-            for field in fieldgroup.fields(relational = False):
84
-                cls_fieldgroup[fieldgroup.name].append(field.name)
85
 
78
 
86
         return """
79
         return """
87
 #Initialisation of {name} class attributes
80
 #Initialisation of {name} class attributes
88
 {name}._fieldtypes = {ftypes}
81
 {name}._fieldtypes = {ftypes}
89
 {name}._linked_types = {ltypes}
82
 {name}._linked_types = {ltypes}
90
-{name}._fieldgroups = {fgroups}
91
 {name}._classtype = {classtype}
83
 {name}._classtype = {classtype}
92
 """.format(
84
 """.format(
93
             name = LeFactory.name2classname(emclass.name),
85
             name = LeFactory.name2classname(emclass.name),
102
                         ]))+']'
94
                         ]))+']'
103
                     ) for lt, ltattr in cls_linked_types.items()
95
                     ) for lt, ltattr in cls_linked_types.items()
104
                 ]))+'}',
96
                 ]))+'}',
105
-            fgroups = repr(cls_fieldgroup),
106
             classtype = repr(emclass.classtype)
97
             classtype = repr(emclass.classtype)
107
         )
98
         )
108
 
99
 

+ 0
- 11
leobject/test/test_lefactory.py View File

62
             #Testing inheritance
62
             #Testing inheritance
63
             self.assertEqual(set(leclass.__bases__), set([dyncode.LeObject, leobject.leclass.LeClass]))
63
             self.assertEqual(set(leclass.__bases__), set([dyncode.LeObject, leobject.leclass.LeClass]))
64
             
64
             
65
-            #Testing _fieldgroups attr
66
-            self.assertEqual(
67
-                set([ fg.name for fg in emclass.fieldgroups()]),
68
-                set(leclass._fieldgroups.keys())
69
-            )
70
-            for fgroup in emclass.fieldgroups():
71
-                self.assertEqual(
72
-                    set([ f.name for f in fgroup.fields(relational=False)]),
73
-                    set(leclass._fieldgroups[fgroup.name])
74
-                )
75
-            
76
             #Testing _linked_types attr
65
             #Testing _linked_types attr
77
             self.assertEqual(
66
             self.assertEqual(
78
                 set([ LeFactory.name2classname(lt.name) for lt in emclass.linked_types()]),
67
                 set([ LeFactory.name2classname(lt.name) for lt in emclass.linked_types()]),

Loading…
Cancel
Save