|
@@ -2,12 +2,12 @@
|
2
|
2
|
|
3
|
3
|
## @package EditorialModel.randomem
|
4
|
4
|
#
|
|
5
|
+# @warning BROKEN because there is no more fieldgroups
|
5
|
6
|
# Provide methods for random EM generation
|
6
|
7
|
|
7
|
8
|
import random
|
8
|
9
|
from EditorialModel.backend.dummy_backend import EmBackendDummy
|
9
|
10
|
from EditorialModel.model import Model
|
10
|
|
-from EditorialModel.fieldgroups import EmFieldGroup
|
11
|
11
|
from EditorialModel.fields import EmField
|
12
|
12
|
from EditorialModel.types import EmType
|
13
|
13
|
from EditorialModel.classtypes import EmClassType
|
|
@@ -85,11 +85,13 @@ class RandomEm(object):
|
85
|
85
|
|
86
|
86
|
for emclass in ed_mod.classes():
|
87
|
87
|
#fieldgroups creation
|
|
88
|
+ """
|
88
|
89
|
if random.randint(0, chances['nofg']) != 0:
|
89
|
90
|
for _ in range(random.randint(1, chances['nfg'])):
|
90
|
91
|
fgdats = cls._rnd_component_datas()
|
91
|
92
|
fgdats['class_id'] = emclass.uid
|
92
|
93
|
ed_mod.create_component('EmFieldGroup', fgdats)
|
|
94
|
+ """
|
93
|
95
|
|
94
|
96
|
#types creation
|
95
|
97
|
if random.randint(0, chances['notype']) != 0:
|
|
@@ -109,24 +111,24 @@ class RandomEm(object):
|
109
|
111
|
|
110
|
112
|
#fields creation
|
111
|
113
|
ft_l = [ ftname for ftname in EmField.fieldtypes_list() if ftname != 'pk' and ftname != 'rel2type']
|
112
|
|
- for emfg in ed_mod.components(EmFieldGroup):
|
|
114
|
+ for emc in ed_mod.components('EmClass'):
|
113
|
115
|
if random.randint(0, chances['nofields']) != 0:
|
114
|
116
|
for _ in range(random.randint(1, chances['nfields'])):
|
115
|
117
|
field_type = ft_l[random.randint(0, len(ft_l) - 1)]
|
116
|
118
|
fdats = cls._rnd_component_datas()
|
117
|
119
|
fdats['fieldtype'] = field_type
|
118
|
|
- fdats['fieldgroup_id'] = emfg.uid
|
|
120
|
+ fdats['class_id'] = emc.uid
|
119
|
121
|
if random.randint(0, chances['optfield']) == 0:
|
120
|
122
|
fdats['optional'] = True
|
121
|
123
|
ed_mod.create_component('EmField', fdats)
|
122
|
124
|
|
123
|
125
|
#rel2type creation (in case none where created before
|
124
|
|
- for emfg in ed_mod.components(EmFieldGroup):
|
|
126
|
+ for emc in ed_mod.components('EmClass'):
|
125
|
127
|
for _ in range(random.randint(0, chances['nr2tfields'])):
|
126
|
128
|
field_type = 'rel2type'
|
127
|
129
|
fdats = cls._rnd_component_datas()
|
128
|
130
|
fdats['fieldtype'] = field_type
|
129
|
|
- fdats['fieldgroup_id'] = emfg.uid
|
|
131
|
+ fdats['class_id'] = emc.uid
|
130
|
132
|
emtypes = ed_mod.components(EmType)
|
131
|
133
|
fdats['rel_to_type_id'] = emtypes[random.randint(0, len(emtypes) - 1)].uid
|
132
|
134
|
if random.randint(0, chances['optfield']) == 0:
|
|
@@ -142,14 +144,14 @@ class RandomEm(object):
|
142
|
144
|
fdats = cls._rnd_component_datas()
|
143
|
145
|
fdats['rel_field_id'] = emrelf.uid
|
144
|
146
|
fdats['fieldtype'] = field_type
|
145
|
|
- fdats['fieldgroup_id'] = emrelf.fieldgroup_id
|
|
147
|
+ fdats['class_id'] = emrelf.class_id
|
146
|
148
|
if random.randint(0, chances['optfield']) == 0:
|
147
|
149
|
fdats['optional'] = True
|
148
|
150
|
ed_mod.create_component('EmField', fdats)
|
149
|
151
|
|
150
|
152
|
#selection optionnal fields
|
151
|
153
|
for emtype in ed_mod.components(EmType):
|
152
|
|
- selectable = [field for fieldgroup in emtype.fieldgroups() for field in fieldgroup.fields() if field.optional]
|
|
154
|
+ selectable = [field for field in emtype.em_class.fields() if field.optional]
|
153
|
155
|
for field in selectable:
|
154
|
156
|
if random.randint(0, chances['seltype']) == 0:
|
155
|
157
|
emtype.select_field(field)
|