Browse Source

Update on graphviz backend and random em generator given the changes in the EM (fieldgroups deletion)

Yann Weber 9 years ago
parent
commit
5236429efd
2 changed files with 10 additions and 8 deletions
  1. 1
    1
      EditorialModel/backend/graphviz.py
  2. 9
    7
      EditorialModel/randomem.py

+ 1
- 1
EditorialModel/backend/graphviz.py View File

87
 
87
 
88
             cntref = 0
88
             cntref = 0
89
             first = True
89
             first = True
90
-            for f in c.fields():
90
+            for f in [ f for f in c.fields() if f.name not in c.em_class.default_fields_list().keys()]:
91
                 if cn == 'EmType' and f.rel_field_id is None:
91
                 if cn == 'EmType' and f.rel_field_id is None:
92
                     
92
                     
93
                     #if not (f.rel_to_type_id is None):
93
                     #if not (f.rel_to_type_id is None):

+ 9
- 7
EditorialModel/randomem.py View File

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

Loading…
Cancel
Save