Browse Source

Fieldgroups are deleted

Yann Weber 9 years ago
parent
commit
10379c6a95

+ 5
- 17
EditorialModel/classes.py View File

@@ -18,9 +18,6 @@ class EmClass(EmComponent):
18 18
 
19 19
     ranked_in = 'classtype'
20 20
     
21
-    ## @brief default fieldgroup name
22
-    default_fieldgroup = '_default'
23
-
24 21
     ## EmClass instanciation
25 22
     # @todo Classtype initialisation and test is not good EmClassType should give an answer or something like that
26 23
     # @todo defines types check for icon and sortcolumn
@@ -60,19 +57,14 @@ class EmClass(EmComponent):
60 57
         for emtype in self.model.components(EditorialModel.types.EmType):
61 58
             if emtype.class_id == self.uid:
62 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 63
         return True
72 64
 
73 65
     ## Retrieve list of the field_groups of this class
74 66
     # @return A list of fieldgroups instance
75
-    def fieldgroups(self):
67
+    def _fieldgroups(self):
76 68
         ret = []
77 69
         for fieldgroup in self.model.components(EditorialModel.fieldgroups.EmFieldGroup):
78 70
             if fieldgroup.class_id == self.uid:
@@ -82,11 +74,7 @@ class EmClass(EmComponent):
82 74
     ## Retrieve list of fields
83 75
     # @return fields [EmField]:
84 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 79
     ## Retrieve list of type of this class
92 80
     # @return types [EditorialModel.types.EmType]:

+ 1
- 1
EditorialModel/components.py View File

@@ -58,7 +58,7 @@ class EmComponent(object):
58 58
                 attributes_dump[attr_name] = attributes_dump[attr_name].uid
59 59
             elif isinstance(attributes_dump[attr_name], MlString):
60 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 63
         return attributes_dump
64 64
 

+ 0
- 75
EditorialModel/fieldgroups.py View File

@@ -1,75 +0,0 @@
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,7 +16,7 @@ import EditorialModel.fieldtypes
16 16
 # Represents one data for a lodel2 document
17 17
 class EmField(EmComponent):
18 18
 
19
-    ranked_in = 'fieldgroup_id'
19
+    ranked_in = 'class_id'
20 20
 
21 21
     ## Instanciate a new EmField
22 22
     # @todo define and test type for icon
@@ -30,10 +30,10 @@ class EmField(EmComponent):
30 30
     # @param nullable bool : If True None values are allowed
31 31
     # @param uniq bool : if True the value should be uniq in the db table
32 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 37
         self.optional = bool(optional)
38 38
 
39 39
         if not internal:
@@ -80,13 +80,13 @@ class EmField(EmComponent):
80 80
 
81 81
     ##@brief Return the EmFieldgroup this EmField belongs to
82 82
     @property
83
-    def fieldgroup(self):
83
+    def _fieldgroup(self):
84 84
         return self.model.component(self.fieldgroup_id)
85 85
     
86 86
     ## @brief Returns the EmClass this EmField belongs to
87 87
     @property
88 88
     def em_class(self):
89
-        return self.fieldgroup.em_class
89
+        return self.model.component(self.class_id)
90 90
 
91 91
     ## @brief Get the fieldtype instance
92 92
     # @return a fieldtype instance
@@ -111,12 +111,14 @@ class EmField(EmComponent):
111 111
     # @return True if valid False if not
112 112
     def check(self):
113 113
         super(EmField, self).check()
114
+        """
114 115
         #Fieldgroup check
115 116
         em_fieldgroup = self.model.component(self.fieldgroup_id)
116 117
         if not em_fieldgroup:
117 118
             raise EmComponentCheckError("fieldgroup_id contains a non existing uid : '%d'" % self.fieldgroup_id)
118 119
         if not isinstance(em_fieldgroup, EditorialModel.fieldgroups.EmFieldGroup):
119 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 122
         #Uniq Name check
121 123
         if len([ f for f in self.em_class.fields() if f.name == self.name]) > 1:
122 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,7 +7,7 @@ import EditorialModel
7 7
 from EditorialModel.migrationhandler.dummy import DummyMigrationHandler
8 8
 from EditorialModel.backend.dummy_backend import EmBackendDummy
9 9
 from EditorialModel.classes import EmClass
10
-from EditorialModel.fieldgroups import EmFieldGroup
10
+#from EditorialModel.fieldgroups import EmFieldGroup
11 11
 from EditorialModel.fields import EmField
12 12
 from EditorialModel.types import EmType
13 13
 from EditorialModel.exceptions import EmComponentCheckError, EmComponentNotExistError, MigrationHandlerChangeError
@@ -17,7 +17,7 @@ import hashlib
17 17
 ## @brief Manages the Editorial Model
18 18
 class Model(object):
19 19
 
20
-    components_class = [EmClass, EmType, EmFieldGroup, EmField]
20
+    components_class = [EmClass, EmType, EmField]
21 21
 
22 22
     ## Constructor
23 23
     #
@@ -33,7 +33,7 @@ class Model(object):
33 33
         self.backend = None
34 34
         self.set_backend(backend)
35 35
 
36
-        self._components = {'uids': {}, 'EmClass': [], 'EmType': [], 'EmField': [], 'EmFieldGroup': []}
36
+        self._components = {'uids': {}, 'EmClass': [], 'EmType': [], 'EmField': []}
37 37
         self.load()
38 38
 
39 39
     def __hash__(self):
@@ -232,7 +232,8 @@ class Model(object):
232 232
         emclass = self._components['uids'][class_uid]
233 233
         if not isinstance(emclass, EditorialModel.classes.EmClass):
234 234
             raise ValueError("The uid '%d' is not an EmClass uid"%class_uid)
235
-
235
+        
236
+        """
236 237
         fgroup_name = EmClass.default_fieldgroup
237 238
 
238 239
         if fgroup_name not in [fg.name for fg in emclass.fieldgroups() ]:
@@ -245,13 +246,14 @@ class Model(object):
245 246
                 if fg.name == fgroup_name:
246 247
                     fgid = fg.uid
247 248
                     break
249
+        """
248 250
 
249 251
         default_fields = emclass.default_fields_list()
250 252
         for fname, fdatas in default_fields.items():
251 253
             if not (fname in [ f.name for f in emclass.fields() ]):
252 254
                 #Adding the field
253 255
                 fdatas['name'] = fname
254
-                fdatas['fieldgroup_id'] = fgid
256
+                fdatas['class_id'] = class_uid
255 257
                 self.create_component('EmField', fdatas)
256 258
         pass
257 259
 

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

@@ -1,548 +1,579 @@
1 1
 {
2 2
  "1": {
3
+  "component": "EmClass",
4
+  "date_create": "Fri Oct 16 11:05:04 2015",
3 5
   "date_update": "Fri Oct 16 11:05:04 2015",
6
+  "sortcolumn": "rank",
4 7
   "classtype": "entity",
5
-  "string": "{\"fre\": \"Texte\"}",
6 8
   "icon": "0",
7
-  "help_text": "",
9
+  "rank": 1,
8 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 14
  "2": {
15
+  "component": "EmClass",
16
+  "date_create": "Fri Oct 16 11:05:04 2015",
15 17
   "date_update": "Fri Oct 16 11:05:04 2015",
18
+  "sortcolumn": "rank",
16 19
   "classtype": "person",
17
-  "string": "{\"fre\": \"Personnes\"}",
18 20
   "icon": "0",
19
-  "help_text": "",
21
+  "rank": 1,
20 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 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 26
  "4": {
27
+  "nullable": false,
37 28
   "date_update": "Fri Oct 16 11:05:04 2015",
38
-  "rel_field_id": null,
39 29
   "optional": false,
40
-  "string": "{\"fre\": \"Titre\"}",
41 30
   "icon": "0",
42
-  "help_text": "",
31
+  "uniq": false,
32
+  "component": "EmField",
33
+  "string": "{\"fre\": \"Titre\"}",
34
+  "class_id": 1,
43 35
   "date_create": "Fri Oct 16 11:05:04 2015",
44 36
   "rank": 1,
45
-  "fieldgroup_id": 3,
46
-  "nullable": false,
47 37
   "fieldtype": "char",
48
-  "uniq": false,
49
-  "name": "titre",
38
+  "help_text": "",
50 39
   "internal": false,
51
-  "component": "EmField"
40
+  "rel_field_id": null,
41
+  "name": "titre"
52 42
  },
53 43
  "5": {
54 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 45
   "class_id": 1,
46
+  "icon": "0",
47
+  "name": "article",
65 48
   "superiors_list": {
66 49
    "parent": [
67 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 63
  "6": {
74 64
   "date_update": "Fri Oct 16 11:05:04 2015",
75
-  "string": "{\"fre\": \"Personne\"}",
65
+  "class_id": 2,
76 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 69
   "fields_list": [
81 70
    10
82 71
   ],
72
+  "string": "{\"fre\": \"Personne\"}",
73
+  "date_create": "Fri Oct 16 11:05:04 2015",
74
+  "component": "EmType",
83 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 79
  "7": {
80
+  "nullable": false,
90 81
   "date_update": "Fri Oct 16 11:05:04 2015",
91
-  "rel_field_id": null,
92 82
   "optional": true,
93
-  "string": "{\"fre\": \"Sous-titre\"}",
94 83
   "icon": "0",
95
-  "help_text": "",
84
+  "uniq": false,
85
+  "component": "EmField",
86
+  "string": "{\"fre\": \"Sous-titre\"}",
87
+  "class_id": 1,
96 88
   "date_create": "Fri Oct 16 11:05:04 2015",
97 89
   "rank": 2,
98
-  "fieldgroup_id": 3,
99
-  "nullable": false,
100 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 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 96
  "9": {
97
+  "nullable": false,
117 98
   "date_update": "Fri Oct 16 11:05:04 2015",
118
-  "rel_field_id": null,
119 99
   "optional": false,
120
-  "string": "{\"fre\": \"Nom\"}",
121 100
   "icon": "0",
122
-  "help_text": "",
101
+  "uniq": false,
102
+  "component": "EmField",
103
+  "string": "{\"fre\": \"Nom\"}",
104
+  "class_id": 2,
123 105
   "date_create": "Fri Oct 16 11:05:04 2015",
124 106
   "rank": 1,
125
-  "fieldgroup_id": 8,
126
-  "nullable": false,
127 107
   "fieldtype": "char",
128
-  "uniq": false,
129
-  "name": "nom",
108
+  "help_text": "",
130 109
   "internal": false,
131
-  "component": "EmField"
110
+  "rel_field_id": null,
111
+  "name": "nom"
132 112
  },
133 113
  "10": {
114
+  "nullable": false,
134 115
   "date_update": "Fri Oct 16 11:05:04 2015",
135
-  "rel_field_id": null,
136 116
   "optional": true,
137
-  "string": "{\"fre\": \"Pr\\u00e9nom\"}",
138 117
   "icon": "0",
139
-  "help_text": "",
118
+  "uniq": false,
119
+  "component": "EmField",
120
+  "string": "{\"fre\": \"Pr\\u00e9nom\"}",
121
+  "class_id": 2,
140 122
   "date_create": "Fri Oct 16 11:05:04 2015",
141 123
   "rank": 2,
142
-  "fieldgroup_id": 8,
143
-  "nullable": false,
144 124
   "fieldtype": "char",
145
-  "uniq": false,
146
-  "name": "prenom",
125
+  "help_text": "",
147 126
   "internal": false,
148
-  "component": "EmField"
127
+  "rel_field_id": null,
128
+  "name": "prenom"
149 129
  },
150 130
  "11": {
131
+  "nullable": false,
151 132
   "date_update": "Fri Oct 16 11:05:04 2015",
152
-  "rel_field_id": null,
153 133
   "optional": false,
154
-  "string": "{\"fre\": \"Auteur\"}",
155 134
   "icon": "0",
156
-  "help_text": "",
135
+  "uniq": false,
136
+  "component": "EmField",
137
+  "string": "{\"fre\": \"Auteur\"}",
138
+  "class_id": 1,
157 139
   "date_create": "Fri Oct 16 11:05:04 2015",
140
+  "rel_to_type_id": 6,
158 141
   "rank": 1,
159
-  "fieldgroup_id": 17,
160
-  "nullable": false,
161 142
   "fieldtype": "rel2type",
162
-  "rel_to_type_id": 6,
163
-  "uniq": false,
164
-  "name": "auteur",
143
+  "help_text": "",
165 144
   "internal": false,
166
-  "component": "EmField"
145
+  "rel_field_id": null,
146
+  "name": "auteur"
167 147
  },
168 148
  "12": {
149
+  "nullable": false,
169 150
   "date_update": "Fri Oct 16 11:05:04 2015",
170
-  "rel_field_id": 11,
171 151
   "optional": false,
172
-  "string": "{\"fre\": \"Adresse\"}",
173 152
   "icon": "0",
174
-  "help_text": "",
153
+  "uniq": false,
154
+  "component": "EmField",
155
+  "string": "{\"fre\": \"Adresse\"}",
156
+  "class_id": 1,
175 157
   "date_create": "Fri Oct 16 11:05:04 2015",
176 158
   "rank": 2,
177
-  "fieldgroup_id": 17,
178
-  "nullable": false,
179 159
   "fieldtype": "char",
180
-  "uniq": false,
181
-  "name": "adresse",
160
+  "help_text": "",
182 161
   "internal": false,
183
-  "component": "EmField"
162
+  "rel_field_id": 11,
163
+  "name": "adresse"
184 164
  },
185 165
  "13": {
166
+  "component": "EmClass",
167
+  "date_create": "Fri Oct 16 11:05:04 2015",
186 168
   "date_update": "Fri Oct 16 11:05:04 2015",
169
+  "sortcolumn": "rank",
187 170
   "classtype": "entity",
188
-  "string": "{\"fre\": \"Publication\"}",
189 171
   "icon": "0",
190
-  "help_text": "",
172
+  "rank": 2,
191 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 177
  "14": {
198 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 179
   "class_id": 13,
180
+  "icon": "0",
181
+  "name": "rubrique",
207 182
   "superiors_list": {
208 183
    "parent": [
209 184
     14,
210 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 190
   "date_create": "Fri Oct 16 11:05:04 2015",
191
+  "component": "EmType",
223 192
   "rank": 1,
224
-  "component": "EmFieldGroup"
193
+  "help_text": "",
194
+  "sortcolumn": "rank"
225 195
  },
226 196
  "16": {
197
+  "nullable": false,
227 198
   "date_update": "Fri Oct 16 11:05:04 2015",
228
-  "rel_field_id": null,
229 199
   "optional": false,
230
-  "string": "{\"fre\": \"Titre\"}",
231 200
   "icon": "0",
232
-  "help_text": "",
201
+  "uniq": false,
202
+  "component": "EmField",
203
+  "string": "{\"fre\": \"Titre\"}",
204
+  "class_id": 13,
233 205
   "date_create": "Fri Oct 16 11:05:04 2015",
234 206
   "rank": 1,
235
-  "fieldgroup_id": 15,
236
-  "nullable": false,
237 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 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 213
  "18": {
214
+  "nullable": false,
254 215
   "date_update": "Fri Oct 16 11:05:04 2015",
255
-  "rel_field_id": null,
256 216
   "optional": true,
257
-  "string": "{\"fre\": \"Age\"}",
258 217
   "icon": "0",
259
-  "help_text": "",
218
+  "uniq": false,
219
+  "component": "EmField",
220
+  "string": "{\"fre\": \"Age\"}",
221
+  "class_id": 2,
260 222
   "date_create": "Fri Oct 16 11:05:04 2015",
261 223
   "rank": 3,
262
-  "fieldgroup_id": 8,
263
-  "nullable": false,
264 224
   "fieldtype": "char",
265
-  "uniq": false,
266
-  "name": "age",
225
+  "help_text": "",
267 226
   "internal": false,
268
-  "component": "EmField"
227
+  "rel_field_id": null,
228
+  "name": "age"
269 229
  },
270 230
  "19": {
271 231
   "date_update": "Fri Oct 16 11:05:04 2015",
272
-  "string": "{\"fre\": \"Num\\u00e9ro\"}",
232
+  "class_id": 13,
273 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 236
   "fields_list": [],
237
+  "string": "{\"fre\": \"Num\\u00e9ro\"}",
238
+  "date_create": "Fri Oct 16 11:05:04 2015",
239
+  "component": "EmType",
278 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 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 244
  "21": {
245
+  "nullable": false,
295 246
   "date_update": "Fri Oct 16 11:05:04 2015",
296
-  "rel_field_id": null,
297 247
   "optional": true,
298
-  "string": "{\"fre\": \"Bleu\"}",
299 248
   "icon": "0",
300
-  "help_text": "",
249
+  "uniq": false,
250
+  "component": "EmField",
251
+  "string": "{\"fre\": \"Bleu\"}",
252
+  "class_id": 1,
301 253
   "date_create": "Fri Oct 16 11:05:04 2015",
302 254
   "rank": 1,
303
-  "fieldgroup_id": 20,
304
-  "nullable": false,
305 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 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 261
  "23": {
262
+  "nullable": false,
322 263
   "date_update": "Fri Oct 16 11:05:04 2015",
323
-  "rel_field_id": null,
324 264
   "optional": false,
325
-  "string": "",
326 265
   "icon": "0",
327
-  "help_text": "",
266
+  "uniq": false,
267
+  "component": "EmField",
268
+  "string": "",
269
+  "class_id": 1,
328 270
   "date_create": "Fri Oct 16 11:05:04 2015",
329
-  "rank": 0,
330
-  "fieldgroup_id": 22,
331
-  "nullable": false,
271
+  "rank": 1,
332 272
   "fieldtype": "integer",
333
-  "uniq": false,
334
-  "name": "class_id",
273
+  "help_text": "",
335 274
   "internal": "automatic",
336
-  "component": "EmField"
275
+  "rel_field_id": null,
276
+  "name": "class_id"
337 277
  },
338 278
  "24": {
279
+  "nullable": false,
339 280
   "date_update": "Fri Oct 16 11:05:04 2015",
340
-  "rel_field_id": null,
281
+  "max_length": 128,
282
+  "icon": "0",
341 283
   "optional": false,
284
+  "component": "EmField",
342 285
   "string": "",
343
-  "icon": "0",
344
-  "help_text": "",
286
+  "class_id": 1,
345 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 288
   "name": "string",
289
+  "rank": 2,
290
+  "fieldtype": "char",
291
+  "help_text": "",
353 292
   "internal": "automatic",
354
-  "component": "EmField"
293
+  "rel_field_id": null,
294
+  "uniq": false
355 295
  },
356 296
  "25": {
297
+  "nullable": false,
357 298
   "date_update": "Fri Oct 16 11:05:04 2015",
358
-  "rel_field_id": null,
359 299
   "optional": false,
360
-  "string": "",
361 300
   "icon": "0",
362
-  "help_text": "",
301
+  "uniq": false,
302
+  "component": "EmField",
303
+  "string": "",
304
+  "class_id": 1,
363 305
   "date_create": "Fri Oct 16 11:05:04 2015",
364
-  "rank": 2,
365
-  "fieldgroup_id": 22,
366
-  "nullable": false,
306
+  "rank": 3,
367 307
   "fieldtype": "integer",
368
-  "uniq": false,
369
-  "name": "type_id",
308
+  "help_text": "",
370 309
   "internal": "automatic",
371
-  "component": "EmField"
310
+  "rel_field_id": null,
311
+  "name": "type_id"
372 312
  },
373 313
  "26": {
314
+  "nullable": false,
374 315
   "date_update": "Fri Oct 16 11:05:04 2015",
375
-  "rel_field_id": null,
376 316
   "optional": false,
377
-  "string": "",
378 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 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 320
   "string": "",
393
-  "class_id": 2,
394
-  "help_text": "",
395
-  "name": "_default",
321
+  "class_id": 1,
396 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 330
  "28": {
331
+  "nullable": false,
401 332
   "date_update": "Fri Oct 16 11:05:04 2015",
402
-  "rel_field_id": null,
403 333
   "optional": false,
404
-  "string": "",
405 334
   "icon": "0",
406
-  "help_text": "",
335
+  "uniq": false,
336
+  "component": "EmField",
337
+  "string": "",
338
+  "class_id": 2,
407 339
   "date_create": "Fri Oct 16 11:05:04 2015",
408
-  "rank": 0,
409
-  "fieldgroup_id": 27,
410
-  "nullable": false,
340
+  "rank": 1,
411 341
   "fieldtype": "integer",
412
-  "uniq": false,
413
-  "name": "class_id",
342
+  "help_text": "",
414 343
   "internal": "automatic",
415
-  "component": "EmField"
344
+  "rel_field_id": null,
345
+  "name": "class_id"
416 346
  },
417 347
  "29": {
348
+  "nullable": false,
418 349
   "date_update": "Fri Oct 16 11:05:04 2015",
419
-  "rel_field_id": null,
350
+  "max_length": 128,
351
+  "icon": "0",
420 352
   "optional": false,
353
+  "component": "EmField",
421 354
   "string": "",
422
-  "icon": "0",
423
-  "help_text": "",
355
+  "class_id": 2,
424 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 357
   "name": "string",
358
+  "rank": 2,
359
+  "fieldtype": "char",
360
+  "help_text": "",
432 361
   "internal": "automatic",
433
-  "component": "EmField"
362
+  "rel_field_id": null,
363
+  "uniq": false
434 364
  },
435 365
  "30": {
366
+  "nullable": false,
436 367
   "date_update": "Fri Oct 16 11:05:04 2015",
437
-  "rel_field_id": null,
438 368
   "optional": false,
439
-  "string": "",
440 369
   "icon": "0",
441
-  "help_text": "",
370
+  "uniq": false,
371
+  "component": "EmField",
372
+  "string": "",
373
+  "class_id": 2,
442 374
   "date_create": "Fri Oct 16 11:05:04 2015",
443
-  "rank": 2,
444
-  "fieldgroup_id": 27,
445
-  "nullable": false,
375
+  "rank": 3,
446 376
   "fieldtype": "integer",
447
-  "uniq": false,
448
-  "name": "type_id",
377
+  "help_text": "",
449 378
   "internal": "automatic",
450
-  "component": "EmField"
379
+  "rel_field_id": null,
380
+  "name": "type_id"
451 381
  },
452 382
  "31": {
383
+  "nullable": false,
453 384
   "date_update": "Fri Oct 16 11:05:04 2015",
454
-  "rel_field_id": null,
455 385
   "optional": false,
456
-  "string": "",
457 386
   "icon": "0",
458
-  "help_text": "",
387
+  "uniq": false,
388
+  "component": "EmField",
389
+  "string": "",
390
+  "class_id": 2,
459 391
   "date_create": "Fri Oct 16 11:05:04 2015",
460
-  "rank": 3,
461
-  "fieldgroup_id": 27,
462
-  "nullable": false,
392
+  "rank": 4,
463 393
   "fieldtype": "pk",
464
-  "uniq": false,
465
-  "name": "lodel_id",
394
+  "help_text": "",
466 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 401
   "date_update": "Fri Oct 16 11:05:04 2015",
402
+  "optional": false,
403
+  "icon": "0",
404
+  "uniq": false,
405
+  "component": "EmField",
471 406
   "string": "",
472 407
   "class_id": 13,
408
+  "date_create": "Fri Oct 16 11:05:04 2015",
409
+  "rank": 1,
410
+  "fieldtype": "integer",
473 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 425
   "date_create": "Fri Oct 16 11:05:04 2015",
426
+  "name": "string",
476 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 436
   "date_update": "Fri Oct 16 11:05:04 2015",
481
-  "rel_field_id": null,
482 437
   "optional": false,
483
-  "string": "",
484 438
   "icon": "0",
485
-  "help_text": "",
439
+  "uniq": false,
440
+  "component": "EmField",
441
+  "string": "",
442
+  "class_id": 13,
486 443
   "date_create": "Fri Oct 16 11:05:04 2015",
487
-  "rank": 0,
488
-  "fieldgroup_id": 32,
489
-  "nullable": false,
444
+  "rank": 3,
490 445
   "fieldtype": "integer",
491
-  "uniq": false,
492
-  "name": "class_id",
446
+  "help_text": "",
493 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 453
   "date_update": "Fri Oct 16 11:05:04 2015",
498
-  "rel_field_id": null,
499 454
   "optional": false,
455
+  "icon": "0",
456
+  "uniq": false,
457
+  "component": "EmField",
500 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 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 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 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 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 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 508
   "rel_field_id": null,
517
-  "optional": false,
518
-  "string": "",
519 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 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 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 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 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 545
   "rel_field_id": null,
534
-  "optional": false,
535
-  "string": "",
536 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 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 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 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 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,7 +11,6 @@ import unittest
11 11
 import EditorialModel
12 12
 from EditorialModel.classes import EmClass
13 13
 from EditorialModel.classtypes import EmClassType
14
-from EditorialModel.fieldgroups import EmFieldGroup
15 14
 from EditorialModel.types import EmType
16 15
 from EditorialModel.fields import EmField
17 16
 from EditorialModel.model import Model
@@ -74,12 +73,8 @@ class TestEmClassCreation(ClassesTestCase):
74 73
         default_fields = ctype['default_fields']
75 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 77
         self.assertEqual(sorted(fnames), sorted(list(default_fields.keys())))
82
-            
83 78
 
84 79
 
85 80
 # Testing class deletion (and associated table drop)
@@ -105,17 +100,10 @@ class TestEmClassDeletion(ClassesTestCase):
105 100
     def test_table_refuse_delete(self):
106 101
         """ Test delete on an EmClass that has fieldgroup """
107 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 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 108
         # TODO check : "table has been deleted but the class has fieldgroup"
121 109
 
@@ -125,34 +113,6 @@ class TestEmClassDeletion(ClassesTestCase):
125 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 116
 # Interface to types
157 117
 class TestEmClassTypes(ClassesTestCase):
158 118
 
@@ -198,9 +158,8 @@ class TestEmClassFields(ClassesTestCase):
198 158
     def test_fields(self):
199 159
         """ testing fields method """
200 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 163
         fields = test_class.fields()
205 164
         self.assertIsInstance(fields, list)
206 165
         for field in fields:

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

@@ -4,7 +4,6 @@ from EditorialModel.model import Model
4 4
 from EditorialModel.components import EmComponent
5 5
 from EditorialModel.classes import EmClass
6 6
 from EditorialModel.types import EmType
7
-from EditorialModel.fieldgroups import EmFieldGroup
8 7
 from EditorialModel.fields import EmField
9 8
 
10 9
 from Lodel.utils.mlstring import MlString
@@ -22,7 +21,7 @@ class TestEmComponent(unittest.TestCase):
22 21
         me1 = Model(EmBackendJson('EditorialModel/test/me.json'))
23 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 25
             comp_l1 = me1.components(comp_class)
27 26
             comp_l2 = me2.components(comp_class)
28 27
 

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

@@ -35,7 +35,7 @@ class FieldTestCase(TestCase):
35 35
 
36 36
     def setUp(self):
37 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 41
 ## TestField (Class)
@@ -48,7 +48,7 @@ class TestField(FieldTestCase):
48 48
     # tests the creation process of a field
49 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 53
         # We check that the field has been added
54 54
         field_records = EM_TEST_OBJECT.component(field.uid)
@@ -61,7 +61,7 @@ class TestField(FieldTestCase):
61 61
     def test_invalid_internal(self):
62 62
         """ Test that internal='object' is reserved for common_fields """
63 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 66
     def test_double_rel2type(self):
67 67
         """ Test the rel2type unicity """
@@ -69,10 +69,10 @@ class TestField(FieldTestCase):
69 69
         emtype = em.components('EmType')[0]
70 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 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 77
     def test_same_name(self):
78 78
         """ Test the name unicity is the same EmClass"""
@@ -80,10 +80,10 @@ class TestField(FieldTestCase):
80 80
         emtype = em.components('EmType')[0]
81 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 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,7 +96,7 @@ class TestField(FieldTestCase):
96 96
 
97 97
         # We create the two fields
98 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 101
         for field in fields:
102 102
             # We check if the delete process was performed to the end
@@ -113,4 +113,3 @@ class TestField(FieldTestCase):
113 113
         """ Test if the EmField.em_class @property method is correct """
114 114
         for field in EM_TEST_OBJECT.components(EmField):
115 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,192 +0,0 @@
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,7 +4,6 @@ from unittest.mock import patch
4 4
 from EditorialModel.model import Model
5 5
 from EditorialModel.classes import EmClass
6 6
 from EditorialModel.types import EmType
7
-from EditorialModel.fieldgroups import EmFieldGroup
8 7
 from EditorialModel.fields import EmField
9 8
 from EditorialModel.components import EmComponent
10 9
 from Lodel.utils.mlstring import MlString
@@ -40,7 +39,7 @@ class TestModel(unittest.TestCase):
40 39
     def test_components(self):
41 40
         """ Test components fetching """
42 41
         uid_l = list()
43
-        for comp_class in [EmClass, EmType, EmField, EmFieldGroup]:
42
+        for comp_class in [EmClass, EmType, EmField]:
44 43
             comp_l = self.ed_mod.components(comp_class)
45 44
             #Testing types of returned components
46 45
             for component in comp_l:
@@ -139,18 +138,11 @@ class TestModel(unittest.TestCase):
139 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 141
             'EmField': {
150 142
                 'cls': EmField,
151 143
                 'cdats': {
152 144
                     'name': 'FooField',
153
-                    'fieldgroup_id': self.ed_mod.components(EmFieldGroup)[0].uid,
145
+                    'class_id': self.ed_mod.components(EmClass)[0].uid,
154 146
                     'fieldtype': 'char',
155 147
                     'max_length': 64,
156 148
                     'optional': True,
@@ -305,7 +297,7 @@ class TestModel(unittest.TestCase):
305 297
 
306 298
     def test_compclass_getter(self):
307 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 301
             cls = Model.emclass_from_name(classname)
310 302
             self.assertNotEqual(cls, False, "emclass_from_name return False when '%s' given as parameter" % classname)
311 303
             self.assertEqual(cls.__name__, classname)
@@ -313,7 +305,7 @@ class TestModel(unittest.TestCase):
313 305
         for classname in ['EmComponent', 'EmFoobar', int, EmClass]:
314 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 309
             self.assertEqual(Model.name_from_emclass(comp_cls), comp_cls.__name__)
318 310
         for comp in self.ed_mod.components(EmField):
319 311
             self.assertEqual(Model.name_from_emclass(comp.__class__), 'EmField')

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

@@ -97,22 +97,6 @@ class TestTypeHierarchy(TypeTestCase):
97 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 100
 class TestDeleteTypes(TypeTestCase):
117 101
 
118 102
     def test_delete_types(self):

+ 4
- 5
EditorialModel/types.py View File

@@ -89,7 +89,7 @@ class EmType(EmComponent):
89 89
 
90 90
     ## Get the list of non empty associated fieldgroups
91 91
     # @return A list of EmFieldGroup instance
92
-    def fieldgroups(self):
92
+    def _fieldgroups(self):
93 93
         fieldgroups = [fieldgroup for fieldgroup in self.em_class.fieldgroups() if len(fieldgroup.fields(self.uid))]
94 94
         return fieldgroups
95 95
 
@@ -102,10 +102,7 @@ class EmType(EmComponent):
102 102
     ## Return the list of associated fields
103 103
     # @return A list of EmField instance
104 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 107
     ## Select_field (Function)
111 108
     #
@@ -323,8 +320,10 @@ class EmType(EmComponent):
323 320
                 raise EmComponentCheckError("The element %d of selected_field is not an EmField but a %s" % (i, str(type(field))))
324 321
             if not field.optional:
325 322
                 raise EmComponentCheckError("The element %d of selected_field is an EmField not optional" % i)
323
+            """
326 324
             if field.fieldgroup_id not in [fg.uid for fg in self.fieldgroups()]:
327 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 328
         for nature, superiors_uid in self.superiors_list.items():
330 329
             for superior_uid in superiors_uid:

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

@@ -200,3 +200,43 @@ class LeDataSourceSQL(DummyDatasource):
200 200
                 prepared_filters[prepared_filter_key] = prepared_filter_value
201 201
 
202 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,19 +75,11 @@ class LeFactory(object):
75 75
         for field in emclass.fields(relational = False):
76 76
             cls_fields[field.name] = LeFactory.fieldtype_construct_from_field(field)
77 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 79
         return """
87 80
 #Initialisation of {name} class attributes
88 81
 {name}._fieldtypes = {ftypes}
89 82
 {name}._linked_types = {ltypes}
90
-{name}._fieldgroups = {fgroups}
91 83
 {name}._classtype = {classtype}
92 84
 """.format(
93 85
             name = LeFactory.name2classname(emclass.name),
@@ -102,7 +94,6 @@ class LeFactory(object):
102 94
                         ]))+']'
103 95
                     ) for lt, ltattr in cls_linked_types.items()
104 96
                 ]))+'}',
105
-            fgroups = repr(cls_fieldgroup),
106 97
             classtype = repr(emclass.classtype)
107 98
         )
108 99
 

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

@@ -62,17 +62,6 @@ class TestLeFactory(TestCase):
62 62
             #Testing inheritance
63 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 65
             #Testing _linked_types attr
77 66
             self.assertEqual(
78 67
                 set([ LeFactory.name2classname(lt.name) for lt in emclass.linked_types()]),

Loading…
Cancel
Save