prieto 7 years ago
parent
commit
0705fc9177

+ 8
- 12
editorial_models/em_simple.py View File

@@ -1,17 +1,13 @@
1 1
 #!/usr/bin/python3
2
-#-*- coding: utf-8 -*-
3 2
 import sys
4
-import os, os.path
5 3
 
6
-sys.path.append(os.path.dirname(os.getcwd()+'/..'))
4
+# A voir si utile dans un lodel installé
7 5
 
8
-from lodel.settings.settings import Settings as settings
9
-settings('globconf.d')
10
-from lodel.settings import Settings
6
+sys.path.insert(0,'lodel/editorial_model')
7
+from model import EditorialModel
11 8
 
12
-from lodel.editorial_model.components import *
13
-from lodel.editorial_model.exceptions import *
14
-from lodel.editorial_model.model import EditorialModel
9
+xml_file = '../examples/em_simple.xml'
10
+pickle_file = '../examples/em_simple.pickle'
15 11
 
16 12
 em = EditorialModel('simpleem', 'Simple editorial model')
17 13
 
@@ -689,7 +685,7 @@ user.new_field(
689 685
     group = user_group, data_handler = 'password', internal = False)
690 686
 
691 687
 
692
-em.save('xmlfile', filename = 'editorial_models/em_simple.xml')
693
-pickle_file = 'examples/em_simple.pickle'
688
+em.save('xmlfile', filename = xml_file)
694 689
 em.save('picklefile', filename = pickle_file)
695
-print("Output written in %s" % pickle_file)
690
+
691
+print("Output written in %s and %s" % (pickle_file, xml_file))

+ 397
- 0
editorial_models/em_test.py View File

@@ -0,0 +1,397 @@
1
+import sys
2
+
3
+sys.path.insert(0,'lodel/editorial_model')
4
+from model import EditorialModel
5
+
6
+xml_file = 'examples/em_test.xml'
7
+pickle_file = 'examples/em_simple.pickle'
8
+
9
+em = EditorialModel('testem', 'Test editorial model')
10
+base_group = em.new_group(
11
+            'base_group', 
12
+            display_name='Base group',
13
+            help_text = 'Base group that implements base EM features (like classtype)')
14
+        
15
+################
16
+# Lodel object #
17
+################
18
+em_abstract = em.new_class(
19
+    'abstract_object', 
20
+    display_name='Abstract lodel object',
21
+    help_text = 'For testing purpose', 
22
+    group=base_group,
23
+    abstract=True)
24
+em_object = em.new_class(
25
+    'object', 
26
+    display_name='Object',
27
+    help_text='Main class for all Em objects', 
28
+    group=base_group,
29
+    abstract=True, 
30
+    parents=em_abstract,)
31
+em_object.new_field(
32
+    'lodel_id', 
33
+    display_name='Lodel identifier',
34
+    help_text='Uniq ID that identify every lodel object',
35
+    group=base_group, 
36
+    data_handler='uniqid', 
37
+    internal=True,)
38
+em_object.new_field(
39
+    'help_text', 
40
+    display_name='Help',
41
+    help_text='A short text that describe the object', 
42
+    group=base_group,
43
+    internal=True, 
44
+    data_handler='text',)
45
+em_object.new_field(
46
+    'date_create', 
47
+    display_name='Creation date', 
48
+    group=base_group,
49
+    data_handler='datetime', 
50
+    now_on_create=True, 
51
+    internal=True,)
52
+em_object.new_field(
53
+    'date_update', 
54
+    display_name='Last update', 
55
+    group=base_group,
56
+    data_handler='datetime', 
57
+    now_on_update=True, 
58
+    internal=True,)
59
+
60
+########################
61
+# Lodel old classtypes #
62
+########################
63
+entitie = em.new_class(
64
+    'entitie', 
65
+    display_name='entitie',
66
+    help_text='Replace old entity classtype', 
67
+    abstract=True, 
68
+    group=base_group, 
69
+    parents=em_object,)
70
+person = em.new_class(
71
+    'person', 
72
+    display_name='Person',
73
+    help_text='Replace old person classtype', 
74
+    abstract=False,
75
+    group=base_group,
76
+    parents=em_object,)
77
+person.new_field(
78
+    'firstname', 
79
+    display_name = {
80
+        'eng': 'Firstname', 
81
+        'fre': 'Prénom',
82
+    },
83
+    data_handler = 'varchar', 
84
+    group = base_group,)
85
+person.new_field(
86
+    'lastname', 
87
+    display_name = {
88
+        'eng': 'Lastname', 
89
+        'fre': 'Nom de famille',
90
+    },
91
+    data_handler = 'varchar',
92
+    group = base_group,)
93
+person.new_field(
94
+    'fullname', 
95
+    display_name = {
96
+        'eng': 'Fullname', 
97
+        'fre': 'Nom complet',
98
+    },
99
+    group = base_group, 
100
+    data_handler = 'Concat',
101
+    field_list = ['firstname', 'lastname'], 
102
+    immutable = True,)
103
+person.new_field(
104
+    'alias', 
105
+    display_name = 'alias',
106
+    help_text = {
107
+        'eng': 'Link to other person class instance that represent the same person',
108
+        'fre': 'Lien vers un ensemble d\'instances de la classe personne représentant le même individu',
109
+    },
110
+    data_handler = 'set', 
111
+    allowed_classes = [person], 
112
+    default = None,
113
+    nullable = True, 
114
+    group = base_group,)
115
+entry = em.new_class(
116
+    'entry', 
117
+    display_name = 'Entry',
118
+    help_text = 'Replace olf entry classtype', 
119
+    abstract = True,
120
+    group = base_group, 
121
+    parents = em_object,)
122
+
123
+#####################
124
+# Editorial classes #
125
+#####################
126
+editorial_group = em.new_group(
127
+    'editorial_abstract', 
128
+    display_name = 'Editorial base',
129
+    help_text = {
130
+        'eng': 'Contains abstract class to handler editorial contents',
131
+        'fre': 'Contient les classes abstraites permetant la gestion de contenu éditorial'
132
+    },
133
+    depends = (base_group,))
134
+
135
+# Classe texte
136
+text = em.new_class(
137
+    'text', 
138
+    display_name = 'Text',
139
+    help_text = 'Abstract class that represent texts',
140
+    group = editorial_group, 
141
+    abstract = True, 
142
+    parents = entitie,)
143
+text.new_field(
144
+    'title', 
145
+    display_name = {'eng': 'Title', 'fre': 'Titre'},
146
+    group = editorial_group, 
147
+    data_handler = 'varchar', 
148
+    nullable = True,)
149
+text.new_field(
150
+    'subtitle', 
151
+    display_name = { 'eng': 'Subtitle', 'fre': 'Sous-titre',},
152
+    group = editorial_group, 
153
+    data_handler = 'varchar', 
154
+    nullable = True,
155
+    default = None)
156
+
157
+# Classe collection
158
+collection = em.new_class(
159
+    'collection', 
160
+    display_name = 'Collection',
161
+    group = editorial_group, 
162
+    abstract = False, 
163
+    parents = entitie)
164
+collection.new_field(
165
+    'title', 
166
+    display_name = 'Title', 
167
+    group = editorial_group,
168
+    data_handler = 'varchar')
169
+
170
+# Classe publication
171
+publication = em.new_class(  'publication',
172
+                    display_name = 'Publication',
173
+                    group = editorial_group,
174
+                    abstract = False,
175
+                    parents = entitie,)
176
+publication.new_field(  'collection',
177
+                display_name = 'Collection',
178
+                group = editorial_group,
179
+                data_handler = 'link',
180
+                default = None,
181
+                nullable = True,
182
+                allowed_classes = [collection],
183
+                back_reference = ('collection', 'publications'))
184
+collection.new_field(   'publications',
185
+                display_name = 'Publications',
186
+                group = editorial_group,
187
+                data_handler = 'list',
188
+                allowed_classes = [publication],
189
+                back_reference = ('publication', 'collection'))
190
+
191
+#########################
192
+#   Texte definition    #
193
+#########################
194
+
195
+section = em.new_class('section',
196
+                    display_name = 'Section',
197
+                    group = editorial_group,
198
+                    abstract = False,
199
+                    parents = text)
200
+subsection = em.new_class(  'subsection',
201
+                    display_name = 'Subsection',
202
+                    group = editorial_group,
203
+                    abstract = False,
204
+                    parents = section)
205
+section.new_field(  'childs',
206
+            display_name = 'Next section',
207
+            group = editorial_group,
208
+            data_handler = 'hierarch',
209
+            allowed_classes = [subsection],
210
+            back_reference = ('subsection', 'parent'),
211
+            default = None,
212
+            nullable = True)
213
+subsection.new_field(   'parent',
214
+                display_name = 'Parent',
215
+                group = editorial_group,
216
+                data_handler = 'link',
217
+                default = None,
218
+                nullable = True,
219
+                allowed_classes = [section],
220
+                back_reference = ('section', 'childs'))
221
+
222
+#####################
223
+# Persons & authors #
224
+#####################
225
+editorial_person_group = em.new_group(  'editorial_person',
226
+                                display_name = 'Editorial person',
227
+                                help_text = {
228
+                                    'eng': 'Introduce the concept of editorial person (authors, translator etc)',
229
+                                    'fre': 'Contient les classes servant à la gestion des personnes editorials (auteurs, traducteur...)',
230
+                                },
231
+                                depends = (editorial_group,))
232
+text_person = em.new_class( 'text_person',
233
+                    display_name = {
234
+                        'eng': 'TextPerson',
235
+                        'fre': 'TextePersonne',
236
+                    },
237
+                    help_text = {
238
+                        'eng': 'Represent a link between someone and a text',
239
+                        'fre': 'Représente un lien entre une personne et un texte',
240
+                    },
241
+                    group = editorial_person_group,
242
+                    abstract = True,
243
+                    parents = entitie,)
244
+bref_textperson_text = text_person.new_field(  'text',
245
+                                        display_name = {
246
+                                            'eng': 'Linked text',
247
+                                            'fre': 'Texte lié',
248
+                                        },
249
+                                        data_handler = 'link',
250
+                                        allowed_classes = [text],
251
+                                        group = editorial_person_group)
252
+bref_textperson_person = text_person.new_field( 'person',
253
+                                        display_name = {
254
+                                            'eng': 'Linked person',
255
+                                            'fre': 'Personne liée',
256
+                                        },
257
+                                        data_handler = 'link',
258
+                                        allowed_classes = [person],
259
+                                        group = editorial_person_group,)
260
+text_person.new_field(  'role',
261
+                display_name = {
262
+                    'eng': 'Person role',
263
+                    'fre': 'Role de la personne',
264
+                },
265
+                data_handler = 'varchar',
266
+                group = editorial_person_group)
267
+
268
+# simple example of linked text / person
269
+person.new_field(   'linked_texts',
270
+                    display_name = {
271
+                        'eng': 'Linked texts',
272
+                        'fre': 'Textes liés',
273
+                        },
274
+                 data_handler = 'list',
275
+                 back_reference = ('Text', 'linked_persons'),
276
+                 group = editorial_person_group,
277
+                 allowed_classes = [text],
278
+                 default = None,
279
+                 nullable = True)
280
+
281
+text.new_field( 'linked_persons',
282
+        display_name = {
283
+            'eng': 'Linked persons',
284
+            'fre': 'Personnes liées',
285
+        },
286
+        data_handler = 'list',
287
+        back_reference = ('Person', 'linked_texts'),
288
+        group = editorial_person_group,
289
+        allowed_classes = [person],
290
+        default = None,
291
+        nullable = True)
292
+
293
+#####################
294
+# Index classes     # <--- Note :   using a different datasource for testing
295
+#####################               purpose
296
+
297
+index_group = em.new_group( 'index_group',
298
+                    display_name = 'Indexes',
299
+                    help_text = {
300
+                        'eng': 'EM class that represents indexes'},
301
+                    depends = (editorial_group,))
302
+
303
+index_abstract = em.new_class(
304
+    'indexAbs',
305
+    display_name = {'eng': 'Abstract Index'},
306
+    help_text = {'eng': 'Abstract class common to each Index classes'},
307
+    abstract = True,
308
+    group = index_group,
309
+    datasources = 'dummy2',
310
+    parents = em_object)
311
+
312
+index_name = index_abstract.new_field(
313
+    'name',
314
+    display_name = {
315
+        'eng': 'name',
316
+        'fre': 'nom'},
317
+    data_handler = 'varchar',
318
+    group = index_group)
319
+
320
+index_value = index_abstract.new_field(
321
+    'value',
322
+    display_name = {
323
+        'eng': 'value',
324
+        'fre': 'valeur'},
325
+    data_handler = 'varchar',
326
+    group = index_group)
327
+
328
+text.new_field( 'indexes',
329
+                display_name = {'eng': 'Indexes', 'fre': 'Indexes'},
330
+                data_handler = 'list',
331
+                back_reference = ('Indexabs', 'texts'),
332
+                allowed_classes = [index_abstract],
333
+                default = None,
334
+                nullable = True,
335
+                group = index_group)
336
+
337
+index_abstract.new_field( 'texts',
338
+                          display_name = {
339
+                              'eng': 'Text referenced by this index',
340
+                              'fre': 'Texte contenant cette index'},
341
+                         data_handler = 'list',
342
+                         back_reference = ('Text', 'indexes'),
343
+                         allowed_classes = [text],
344
+                         group = index_group)
345
+
346
+index_theme = em.new_class(
347
+                            'indexTheme',
348
+                            display_name = {
349
+                                'eng': 'Thematic index',
350
+                                'fre': 'Index thématique'},
351
+                           group = index_group,
352
+                           datasources = 'dummy2',
353
+                           parents = index_abstract)
354
+
355
+index_theme_theme = index_abstract.new_field(
356
+    'theme',
357
+    display_name = {
358
+        'eng': 'theme'},
359
+    data_handler = 'varchar',
360
+    group = index_group)
361
+
362
+#############
363
+#   USERS   #
364
+#############
365
+
366
+user_group = em.new_group(
367
+    'users', display_name = 'Lodel users',
368
+    help_text = 'Group that handle users en perm')
369
+
370
+user = em.new_class(
371
+    'user', display_name = 'Lodel user', help_text = 'Represent a lodel user',
372
+    group = user_group, abstract = False)
373
+
374
+user.new_field(
375
+    'id', display_name = 'user identifier', help_text = 'Uniq ID',
376
+    group = user_group, data_handler = 'uniqid', internal = True)
377
+
378
+user.new_field(
379
+    'firstname', display_name = 'Firstname',
380
+    group = user_group, data_handler = 'varchar', internal = False)
381
+
382
+user.new_field(
383
+    'lastname', display_name = 'Lastname',
384
+    group = user_group, data_handler = 'varchar', internal = False)
385
+
386
+user.new_field(
387
+    'login', display_name = 'user login', help_text = 'login',
388
+    group = user_group, data_handler = 'varchar', uniq = True, internal = False)
389
+
390
+user.new_field(
391
+    'password', display_name = 'Password',
392
+    group = user_group, data_handler = 'password', internal = False)
393
+
394
+em.save('xmlfile', filename = xml_file)
395
+em.save('picklefile', filename = pickle_file)
396
+
397
+print("Output written in %s and %s" % (pickle_file, xml_file))

+ 1
- 1
management/commands/create_site.py View File

@@ -4,7 +4,7 @@ from flask.templating import render_template_string
4 4
 from flask_script import Command, Option
5 5
 
6 6
 
7
-class LodelCommand(Command):
7
+class CreateSite(Command):
8 8
     
9 9
     option_list = (
10 10
         Option('--name', '-n', dest='name'),

+ 0
- 397
management/commands/em_test.py View File

@@ -1,397 +0,0 @@
1
-from flask_script import Command
2
-from lodel.editorial_model.model import EditorialModel
3
-
4
-class LodelCommand(Command):
5
-    
6
-    def run(self):
7
-        em = EditorialModel('testem', 'Test editorial model')
8
-        base_group = em.new_group(
9
-            'base_group', 
10
-            display_name='Base group',
11
-            help_text = 'Base group that implements base EM features (like classtype)')
12
-        
13
-        ################
14
-        # Lodel object #
15
-        ################
16
-        em_abstract = em.new_class(
17
-            'abstract_object', 
18
-            display_name='Abstract lodel object',
19
-            help_text = 'For testing purpose', 
20
-            group=base_group,
21
-            abstract=True)
22
-        em_object = em.new_class(
23
-            'object', 
24
-            display_name='Object',
25
-            help_text='Main class for all Em objects', 
26
-            group=base_group,
27
-            abstract=True, 
28
-            parents=em_abstract,)
29
-        em_object.new_field(
30
-            'lodel_id', 
31
-            display_name='Lodel identifier',
32
-            help_text='Uniq ID that identify every lodel object',
33
-            group=base_group, 
34
-            data_handler='uniqid', 
35
-            internal=True,)
36
-        em_object.new_field(
37
-            'help_text', 
38
-            display_name='Help',
39
-            help_text='A short text that describe the object', 
40
-            group=base_group,
41
-            internal=True, 
42
-            data_handler='text',)
43
-        em_object.new_field(
44
-            'date_create', 
45
-            display_name='Creation date', 
46
-            group=base_group,
47
-            data_handler='datetime', 
48
-            now_on_create=True, 
49
-            internal=True,)
50
-        em_object.new_field(
51
-            'date_update', 
52
-            display_name='Last update', 
53
-            group=base_group,
54
-            data_handler='datetime', 
55
-            now_on_update=True, 
56
-            internal=True,)
57
-
58
-        ########################
59
-        # Lodel old classtypes #
60
-        ########################
61
-        entitie = em.new_class(
62
-            'entitie', 
63
-            display_name='entitie',
64
-            help_text='Replace old entity classtype', 
65
-            abstract=True, 
66
-            group=base_group, 
67
-            parents=em_object,)
68
-        person = em.new_class(
69
-            'person', 
70
-            display_name='Person',
71
-            help_text='Replace old person classtype', 
72
-            abstract=False,
73
-            group=base_group,
74
-            parents=em_object,)
75
-        person.new_field(
76
-            'firstname', 
77
-            display_name = {
78
-                'eng': 'Firstname', 
79
-                'fre': 'Prénom',
80
-            },
81
-            data_handler = 'varchar', 
82
-            group = base_group,)
83
-        person.new_field(
84
-            'lastname', 
85
-            display_name = {
86
-                'eng': 'Lastname', 
87
-                'fre': 'Nom de famille',
88
-            },
89
-            data_handler = 'varchar',
90
-            group = base_group,)
91
-        person.new_field(
92
-            'fullname', 
93
-            display_name = {
94
-                'eng': 'Fullname', 
95
-                'fre': 'Nom complet',
96
-            },
97
-            group = base_group, 
98
-            data_handler = 'Concat',
99
-            field_list = ['firstname', 'lastname'], 
100
-            immutable = True,)
101
-        person.new_field(
102
-            'alias', 
103
-            display_name = 'alias',
104
-            help_text = {
105
-                'eng': 'Link to other person class instance that represent the same person',
106
-                'fre': 'Lien vers un ensemble d\'instances de la classe personne représentant le même individu',
107
-            },
108
-            data_handler = 'set', 
109
-            allowed_classes = [person], 
110
-            default = None,
111
-            nullable = True, 
112
-            group = base_group,)
113
-        entry = em.new_class(
114
-            'entry', 
115
-            display_name = 'Entry',
116
-            help_text = 'Replace olf entry classtype', 
117
-            abstract = True,
118
-            group = base_group, 
119
-            parents = em_object,)
120
-        
121
-        #####################
122
-        # Editorial classes #
123
-        #####################
124
-        editorial_group = em.new_group(
125
-            'editorial_abstract', 
126
-            display_name = 'Editorial base',
127
-            help_text = {
128
-                'eng': 'Contains abstract class to handler editorial contents',
129
-                'fre': 'Contient les classes abstraites permetant la gestion de contenu éditorial'
130
-            },
131
-            depends = (base_group,))
132
-        
133
-        # Classe texte
134
-        text = em.new_class(
135
-            'text', 
136
-            display_name = 'Text',
137
-            help_text = 'Abstract class that represent texts',
138
-            group = editorial_group, 
139
-            abstract = True, 
140
-            parents = entitie,)
141
-        text.new_field(
142
-            'title', 
143
-            display_name = {'eng': 'Title', 'fre': 'Titre'},
144
-            group = editorial_group, 
145
-            data_handler = 'varchar', 
146
-            nullable = True,)
147
-        text.new_field(
148
-            'subtitle', 
149
-            display_name = { 'eng': 'Subtitle', 'fre': 'Sous-titre',},
150
-            group = editorial_group, 
151
-            data_handler = 'varchar', 
152
-            nullable = True,
153
-            default = None)
154
-        
155
-        # Classe collection
156
-        collection = em.new_class(
157
-            'collection', 
158
-            display_name = 'Collection',
159
-            group = editorial_group, 
160
-            abstract = False, 
161
-            parents = entitie)
162
-        collection.new_field(
163
-            'title', 
164
-            display_name = 'Title', 
165
-            group = editorial_group,
166
-            data_handler = 'varchar')
167
-        
168
-        # Classe publication
169
-        publication = em.new_class(  'publication',
170
-                            display_name = 'Publication',
171
-                            group = editorial_group,
172
-                            abstract = False,
173
-                            parents = entitie,)
174
-        publication.new_field(  'collection',
175
-                        display_name = 'Collection',
176
-                        group = editorial_group,
177
-                        data_handler = 'link',
178
-                        default = None,
179
-                        nullable = True,
180
-                        allowed_classes = [collection],
181
-                        back_reference = ('collection', 'publications'))
182
-        collection.new_field(   'publications',
183
-                        display_name = 'Publications',
184
-                        group = editorial_group,
185
-                        data_handler = 'list',
186
-                        allowed_classes = [publication],
187
-                        back_reference = ('publication', 'collection'))
188
-
189
-        #########################
190
-        #   Texte definition    #
191
-        #########################
192
-
193
-        section = em.new_class('section',
194
-                            display_name = 'Section',
195
-                            group = editorial_group,
196
-                            abstract = False,
197
-                            parents = text)
198
-        subsection = em.new_class(  'subsection',
199
-                            display_name = 'Subsection',
200
-                            group = editorial_group,
201
-                            abstract = False,
202
-                            parents = section)
203
-        section.new_field(  'childs',
204
-                    display_name = 'Next section',
205
-                    group = editorial_group,
206
-                    data_handler = 'hierarch',
207
-                    allowed_classes = [subsection],
208
-                    back_reference = ('subsection', 'parent'),
209
-                    default = None,
210
-                    nullable = True)
211
-        subsection.new_field(   'parent',
212
-                        display_name = 'Parent',
213
-                        group = editorial_group,
214
-                        data_handler = 'link',
215
-                        default = None,
216
-                        nullable = True,
217
-                        allowed_classes = [section],
218
-                        back_reference = ('section', 'childs'))
219
-
220
-        #####################
221
-        # Persons & authors #
222
-        #####################
223
-        editorial_person_group = em.new_group(  'editorial_person',
224
-                                        display_name = 'Editorial person',
225
-                                        help_text = {
226
-                                            'eng': 'Introduce the concept of editorial person (authors, translator etc)',
227
-                                            'fre': 'Contient les classes servant à la gestion des personnes editorials (auteurs, traducteur...)',
228
-                                        },
229
-                                        depends = (editorial_group,))
230
-        text_person = em.new_class( 'text_person',
231
-                            display_name = {
232
-                                'eng': 'TextPerson',
233
-                                'fre': 'TextePersonne',
234
-                            },
235
-                            help_text = {
236
-                                'eng': 'Represent a link between someone and a text',
237
-                                'fre': 'Représente un lien entre une personne et un texte',
238
-                            },
239
-                            group = editorial_person_group,
240
-                            abstract = True,
241
-                            parents = entitie,)
242
-        bref_textperson_text = text_person.new_field(  'text',
243
-                                                display_name = {
244
-                                                    'eng': 'Linked text',
245
-                                                    'fre': 'Texte lié',
246
-                                                },
247
-                                                data_handler = 'link',
248
-                                                allowed_classes = [text],
249
-                                                group = editorial_person_group)
250
-        bref_textperson_person = text_person.new_field( 'person',
251
-                                                display_name = {
252
-                                                    'eng': 'Linked person',
253
-                                                    'fre': 'Personne liée',
254
-                                                },
255
-                                                data_handler = 'link',
256
-                                                allowed_classes = [person],
257
-                                                group = editorial_person_group,)
258
-        text_person.new_field(  'role',
259
-                        display_name = {
260
-                            'eng': 'Person role',
261
-                            'fre': 'Role de la personne',
262
-                        },
263
-                        data_handler = 'varchar',
264
-                        group = editorial_person_group)
265
-
266
-        # simple example of linked text / person
267
-        person.new_field(   'linked_texts',
268
-                            display_name = {
269
-                                'eng': 'Linked texts',
270
-                                'fre': 'Textes liés',
271
-                                },
272
-                         data_handler = 'list',
273
-                         back_reference = ('Text', 'linked_persons'),
274
-                         group = editorial_person_group,
275
-                         allowed_classes = [text],
276
-                         default = None,
277
-                         nullable = True)
278
-
279
-        text.new_field( 'linked_persons',
280
-                display_name = {
281
-                    'eng': 'Linked persons',
282
-                    'fre': 'Personnes liées',
283
-                },
284
-                data_handler = 'list',
285
-                back_reference = ('Person', 'linked_texts'),
286
-                group = editorial_person_group,
287
-                allowed_classes = [person],
288
-                default = None,
289
-                nullable = True)
290
-
291
-        #####################
292
-        # Index classes     # <--- Note :   using a different datasource for testing
293
-        #####################               purpose
294
-
295
-        index_group = em.new_group( 'index_group',
296
-                            display_name = 'Indexes',
297
-                            help_text = {
298
-                                'eng': 'EM class that represents indexes'},
299
-                            depends = (editorial_group,))
300
-
301
-        index_abstract = em.new_class(
302
-            'indexAbs',
303
-            display_name = {'eng': 'Abstract Index'},
304
-            help_text = {'eng': 'Abstract class common to each Index classes'},
305
-            abstract = True,
306
-            group = index_group,
307
-            datasources = 'dummy2',
308
-            parents = em_object)
309
-
310
-        index_name = index_abstract.new_field(
311
-            'name',
312
-            display_name = {
313
-                'eng': 'name',
314
-                'fre': 'nom'},
315
-            data_handler = 'varchar',
316
-            group = index_group)
317
-
318
-        index_value = index_abstract.new_field(
319
-            'value',
320
-            display_name = {
321
-                'eng': 'value',
322
-                'fre': 'valeur'},
323
-            data_handler = 'varchar',
324
-            group = index_group)
325
-
326
-        text.new_field( 'indexes',
327
-                        display_name = {'eng': 'Indexes', 'fre': 'Indexes'},
328
-                        data_handler = 'list',
329
-                        back_reference = ('Indexabs', 'texts'),
330
-                        allowed_classes = [index_abstract],
331
-                        default = None,
332
-                        nullable = True,
333
-                        group = index_group)
334
-
335
-        index_abstract.new_field( 'texts',
336
-                                  display_name = {
337
-                                      'eng': 'Text referenced by this index',
338
-                                      'fre': 'Texte contenant cette index'},
339
-                                 data_handler = 'list',
340
-                                 back_reference = ('Text', 'indexes'),
341
-                                 allowed_classes = [text],
342
-                                 group = index_group)
343
-
344
-        index_theme = em.new_class(
345
-                                    'indexTheme',
346
-                                    display_name = {
347
-                                        'eng': 'Thematic index',
348
-                                        'fre': 'Index thématique'},
349
-                                   group = index_group,
350
-                                   datasources = 'dummy2',
351
-                                   parents = index_abstract)
352
-
353
-        index_theme_theme = index_abstract.new_field(
354
-            'theme',
355
-            display_name = {
356
-                'eng': 'theme'},
357
-            data_handler = 'varchar',
358
-            group = index_group)
359
-
360
-        #############
361
-        #   USERS   #
362
-        #############
363
-
364
-        user_group = em.new_group(
365
-            'users', display_name = 'Lodel users',
366
-            help_text = 'Group that handle users en perm')
367
-
368
-        user = em.new_class(
369
-            'user', display_name = 'Lodel user', help_text = 'Represent a lodel user',
370
-            group = user_group, abstract = False)
371
-
372
-        user.new_field(
373
-            'id', display_name = 'user identifier', help_text = 'Uniq ID',
374
-            group = user_group, data_handler = 'uniqid', internal = True)
375
-
376
-        user.new_field(
377
-            'firstname', display_name = 'Firstname',
378
-            group = user_group, data_handler = 'varchar', internal = False)
379
-
380
-        user.new_field(
381
-            'lastname', display_name = 'Lastname',
382
-            group = user_group, data_handler = 'varchar', internal = False)
383
-
384
-        user.new_field(
385
-            'login', display_name = 'user login', help_text = 'login',
386
-            group = user_group, data_handler = 'varchar', uniq = True, internal = False)
387
-
388
-        user.new_field(
389
-            'password', display_name = 'Password',
390
-            group = user_group, data_handler = 'password', internal = False)
391
-
392
-
393
-        #em.save('xmlfile', filename = 'examples/em_test.xml')
394
-        pickle_file = 'examples/em_test.pickle'
395
-        em.save('picklefile', filename = pickle_file)
396
-        print("Output written in %s" % pickle_file)
397
-

+ 1
- 1
management/commands/generate_dyncode.py View File

@@ -2,7 +2,7 @@ from flask_script import Command, Option
2 2
 
3 3
 from management.utils import generate_dyncode
4 4
 
5
-class LodelCommand(Command):
5
+class GenerateDyncode(Command):
6 6
 
7 7
     option_list = (
8 8
         Option('--model', '-m', dest='model_file'),

+ 3
- 3
management/commands/refresh_dyncode.py View File

@@ -1,7 +1,7 @@
1 1
 from flask_script import Command, Option
2
-from lodel.management.utils import generate_dyncode
2
+from management.utils import generate_dyncode
3 3
 
4
-class LodelCommand(Command):
4
+class RefreshDyncode(Command):
5 5
 
6 6
     option_list = (
7 7
         Option('--model', '-m', dest='model_file'),
@@ -16,7 +16,7 @@ class LodelCommand(Command):
16 16
     def run(self, model_file, translator, output_filename):
17 17
         dyncode = generate_dyncode(model_file, translator)
18 18
         with open(output_filename, 'w+') as out_fd:
19
-        out_fd.write(dyncode)
19
+            out_fd.write(dyncode)
20 20
         out_fd.close()
21 21
         print("The dynamic code %s has been updated to %s" % (model_file, output_filename)) 
22 22
 

Loading…
Cancel
Save