prieto 8 years ago
parent
commit
104f66d37e
2 changed files with 98 additions and 362 deletions
  1. 8
    1
      Makefile.am
  2. 90
    361
      em_test.py

+ 8
- 1
Makefile.am View File

@@ -43,10 +43,17 @@ deb: dist
43 43
 em_test: em_test.py
44 44
 	$(python) em_test.py
45 45
 
46
+# 23/11 Editoral model update
47
+em_simple: editorial_models/em_simple.py
48
+	$(python) editorial_models/em_simple.py
49
+	
46 50
 # generate leapi dynamic code
47
-dyncode: examples/em_test.pickle
51
+dyncode: examples/em_test.pickle 
48 52
 	$(python) scripts/refreshdyn.py examples/em_test.pickle $(dyncode_filename) && echo -e "\n\nCode generated in $(dyncode_filename)"
49 53
 
54
+dyncode_simple: examples/em_simple.pickle 
55
+	$(python) scripts/refreshdyn.py examples/em_simple.pickle $(dyncode_filename) && echo -e "\n\nCode generated in $(dyncode_filename)"
56
+
50 57
 # run tests
51 58
 checks: runtest
52 59
 	./runtest -v

+ 90
- 361
em_test.py View File

@@ -42,6 +42,14 @@ em_object.new_field(    'lodel_id',
42 42
                         data_handler = 'uniqid',
43 43
                         internal = True,
44 44
 )
45
+em_object.new_field(    'help_text',
46
+                        display_name = 'Help',
47
+                        help_text = 'A short text that describe the object',
48
+                        group = base_group,
49
+                        internal = True,
50
+                        data_handler = 'text',
51
+)
52
+
45 53
 em_object.new_field(    'date_create',
46 54
                         display_name = 'Creation date',
47 55
                         group = base_group,
@@ -56,6 +64,10 @@ em_object.new_field(    'date_update',
56 64
                         now_on_update = True,
57 65
                         internal = True,
58 66
 )
67
+
68
+########################
69
+# Lodel old classtypes #
70
+########################
59 71
 entitie = em.new_class( 'entitie',
60 72
                         display_name = 'entitie',
61 73
                         help_text = 'Replace old entity classtype',
@@ -63,13 +75,10 @@ entitie = em.new_class( 'entitie',
63 75
                         group = base_group,
64 76
                         parents = em_object,
65 77
 )
66
-########################
67
-# Base group
68
-########################
69 78
 
70 79
 person = em.new_class(  'person',
71 80
                         display_name = 'Person',
72
-                        help_text = 'Person type',
81
+                        help_text = 'Replace old person classtype',
73 82
                         abstract = False,
74 83
                         group = base_group,
75 84
                         parents = em_object,
@@ -91,47 +100,36 @@ person.new_field(   'lastname',
91 100
                     data_handler = 'varchar',
92 101
                     group = base_group,
93 102
 )
94
-
95
-# person.new_field(   'role',
96
-#                     display_name = {
97
-#                         'eng': 'Role',
98
-#                         'fre': 'Rôle',
99
-#                     },
100
-#                     data_handler = 'varchar',
101
-#                     group = base_group,
102
-# )
103
-
104
-entry = em.new_class(   'entry',
105
-                        display_name = 'Entry',
106
-                        help_text = 'Entry type',
107
-                        abstract = False,
108
-                        group = base_group,
109
-                        parents = em_object,
110
-)
111
-entry.new_field(    'name',
103
+person.new_field(   'fullname',
112 104
                     display_name = {
113
-                        'eng': 'Name',
114
-                        'fre': 'Nom',
105
+                        'eng': 'Fullname',
106
+                        'fre': 'Nom complet',
115 107
                     },
116
-                    data_handler = 'varchar',
117 108
                     group = base_group,
109
+                    data_handler = 'Concat',
110
+                    field_list = ['firstname', 'lastname'],
111
+                    immutable = True,
118 112
 )
119
-entry.new_field(    'description',
120
-                    display_name = {
121
-                        'eng': 'Description',
122
-                        'fre': 'Description',
113
+person.new_field(   'alias',
114
+                    display_name = 'alias',
115
+                    help_text = {
116
+                        'eng': 'Link to other person class instance that represent the same person',
117
+                        'fre': 'Lien vers un ensemble d\'instances de la classe personne représentant le même individu',
123 118
                     },
124
-                    data_handler = 'text',
119
+                    data_handler = 'set',
120
+                    allowed_classes = [person],
121
+                    default = None,
122
+                    nullable = True,
125 123
                     group = base_group,
126 124
 )
127 125
 
128
-entry.new_field(    'role',
129
-                    display_name = {
130
-                        'eng': 'Role',
131
-                        'fre': 'Rôle',
132
-                    },
133
-                    data_handler = 'varchar',
134
-                    group = base_group,
126
+
127
+entry = em.new_class(   'entry',
128
+                        display_name = 'Entry',
129
+                        help_text = 'Replace olf entry classtype',
130
+                        abstract = True,
131
+                        group = base_group,
132
+                        parents = em_object,
135 133
 )
136 134
 
137 135
 #####################
@@ -147,7 +145,6 @@ editorial_group = em.new_group( 'editorial_abstract',
147 145
                                 depends = (base_group,)
148 146
 )
149 147
 
150
-################################### Texts ##########################################################
151 148
 # Classe texte
152 149
 text = em.new_class(   'text',
153 150
                         display_name = 'Text',
@@ -160,7 +157,7 @@ text = em.new_class(   'text',
160 157
 text.new_field(    'title',
161 158
                     display_name = {'eng': 'Title', 'fre': 'Titre'},
162 159
                     group = editorial_group,
163
-                    data_handler = 'text',
160
+                    data_handler = 'varchar',
164 161
                     nullable = True,)
165 162
 text.new_field(    'subtitle',
166 163
                     display_name = {
@@ -168,344 +165,76 @@ text.new_field(    'subtitle',
168 165
                         'fre': 'Sous-titre',
169 166
                     },
170 167
                     group = editorial_group,
171
-                    data_handler = 'text',
172
-                    nullable = True,
173
-                    default = None)
174
-text.new_field(    'language',
175
-                    display_name = {
176
-                        'eng': 'Language',
177
-                        'fre': 'Langue',
178
-                    },
179
-                    group = editorial_group,
180 168
                     data_handler = 'varchar',
181 169
                     nullable = True,
182 170
                     default = None)
183
-text.new_field(    'text',
184
-                    display_name = {
185
-                        'eng': 'Text',
186
-                        'fre': 'Texte',
187
-                    },
188
-                    group = editorial_group,
189
-                    data_handler = 'text',
190
-                    nullable = True,
191
-                    default = None)
192
-text.new_field(    'pub_date',
193
-                    display_name = {
194
-                        'eng': 'Publication date',
195
-                        'fre': 'Date de publication',
196
-                    },
197
-                    group = editorial_group,
198
-                    data_handler = 'datetime',
199
-                    nullable = True,
200
-                    default = None)
201
-text.new_field(    'footnotes',
202
-                    display_name = {
203
-                        'eng': 'Footnotes',
204
-                        'fre': 'Notes de bas de page',
205
-                    },
206
-                    group = editorial_group,
207
-                    data_handler = 'text',
208
-                    nullable = True,
209
-                    default = None)
210
-text.new_field(    'linked_entries',
211
-                    display_name = {
212
-                        'eng': 'Related entries',
213
-                        'fre': 'Indices liés',
214
-                    },
215
-                    group = editorial_group,
216
-                    data_handler = 'list',
217
-                    nullable = True,
218
-                    allowed_classes = [entry],
219
-                    back_reference = ('entry', 'linked_texts'),
220
-                    default = None
221
-)
222
-entry.new_field(    'linked_texts',
223
-                    display_name = {
224
-                        'eng': 'Related text',
225
-                        'fre': 'Texte lié ',
226
-                    },
227
-                    data_handler = 'list',
228
-                    nullable = True,
229
-                    allowed_classes = [text],
230
-                    group = editorial_group,
231
-                    back_reference = ('text', 'linked_entries'),
232
-                    default = None
233
-)
234
-# Classe article
235
-article = em.new_class( 'article',
236
-                        display_name = 'Article',
237
-                        group = editorial_group,
238
-                        abstract = False,
239
-                        parents = text)
240
-article.new_field(  'abstract',
241
-                    display_name = {
242
-                        'eng': 'Abstract',
243
-                        'fre': 'Résumé',
244
-                    },
245
-                    group = editorial_group,
246
-                    data_handler = 'text'
247
-)
248
-article.new_field(  'appendix',
249
-                    display_name = {
250
-                        'eng': 'Appendix',
251
-                        'fre': 'Appendice',
252
-                    },
253
-                    group = editorial_group,
254
-                    data_handler = 'text'
255
-)
256
-article.new_field(  'bibliography',
257
-                    display_name = {
258
-                        'eng': 'Bibliography',
259
-                        'fre': 'Bibliographie',
260
-                    },
261
-                    group = editorial_group,
262
-                    data_handler = 'text'
263
-)
264
-article.new_field(  'author_note',
265
-                    display_name = {
266
-                        'eng': 'Author note',
267
-                        'fre': "Note de l'auteur",
268
-                    },
269
-                    group = editorial_group,
270
-                    data_handler = 'text'
271
-)
272
-# Classe Review 
273
-review = em.new_class( 'review',
274
-                        display_name = 'Review',
275
-                        group = editorial_group,
276
-                        abstract = False,
277
-                        parents = text)
278
-review.new_field(   'reference',
279
-                    display_name = {
280
-                        'eng': 'Reference',
281
-                        'fre': "Référence",
282
-                    },
283
-                    group = editorial_group,
284
-                    data_handler = 'text'
285
-)
286 171
 
287
-###################################### Containers ###########################################
288
-# Classe container
289
-container = em.new_class(  'container',
290
-                            display_name = 'Container',
172
+# Classe collection
173
+collection = em.new_class(  'collection',
174
+                            display_name = 'Collection',
291 175
                             group = editorial_group,
292
-                            abstract = True,
176
+                            abstract = False,
293 177
                             parents = entitie)
294
-container.new_field(   'title',
178
+collection.new_field(   'title',
295 179
                         display_name = 'Title',
296 180
                         group = editorial_group,
297
-                        data_handler = 'text'
298
-)
299
-container.new_field(   'subtitle',
300
-                        display_name = 'Subtitle',
301
-                        group = editorial_group,
302
-                        data_handler = 'text'
303
-)
304
-container.new_field(   'language',
305
-                        display_name = {
306
-                            'eng' : 'Language',
307
-                            'fre' : 'Langue',
308
-                        },
309
-                        group = editorial_group,
310 181
                         data_handler = 'varchar'
311 182
 )
312
-container.new_field(    'linked_directors',
313
-                    display_name = {
314
-                        'eng': 'Directors',
315
-                        'fre': 'Directeurs',
316
-                    },
317
-                    group = editorial_group,
318
-                    data_handler = 'list',
319
-                    nullable = True,
320
-                    allowed_classes = [person],
321
-                    back_reference = ('person', 'linked_containers'),
322
-                    default = None
323
-)
324
-person.new_field(   'linked_containers',
325
-                    display_name = {
326
-                        'eng': 'Director of ',
327
-                        'fre': 'Directeur de ',
328
-                    },
329
-                    group = editorial_group,
330
-                    data_handler = 'list',
331
-                    nullable = True,
332
-                    allowed_classes = [container],
333
-                    back_reference = ('container', 'linked_directors'),
334
-                    default = None
335
-)
336
-container.new_field(    'description',
337
-                    display_name = {
338
-                        'eng': 'Description',
339
-                        'fre': 'Description',
340
-                    },
341
-                    data_handler = 'text',
342
-                    group = editorial_group,
343
-)
344
-container.new_field(    'publisher_note',
345
-                    display_name = {
346
-                        'eng': 'Publisher note',
347
-                        'fre': "Note de l'éditeur",
348
-                    },
349
-                    data_handler = 'text',
350
-                    group = editorial_group,
351
-)
352 183
 
353
-# Classe collection
354
-collection = em.new_class(  'collection',
355
-                            display_name = 'Collection',
356
-                            group = editorial_group,
357
-                            abstract = False,
358
-                            parents = container)
359
-collection.new_field(    'issn',
360
-                    display_name = {
361
-                        'eng': 'ISSN',
362
-                        'fre': "ISSN",
363
-                    },
364
-                    data_handler = 'varchar',
365
-                    group = editorial_group,
366
-)
367
-# Classe Publication : Pour gérer les back_references vers issue ou part
184
+# Classe publication
368 185
 publication = em.new_class(  'publication',
369 186
                             display_name = 'Publication',
370 187
                             group = editorial_group,
371
-                            abstract = True,
372
-                            parents = container)
373
-publication.new_field(  'linked_texts',
374
-                        display_name = {
375
-                            'eng': 'Text',
376
-                            'fre': 'Texte',
377
-                        },
378
-                      data_handler = 'list',
379
-                    nullable = True,
380
-                    allowed_classes = [text],
381
-                    group = editorial_group,
382
-                    back_reference = ('text', 'linked_container'),
383
-                    default = None
384
-)
385
-text.new_field(    'linked_container',
386
-                    display_name = {
387
-                        'eng': 'Container',
388
-                        'fre': 'Conteneur',
389
-                    },
390
-                    data_handler = 'link',
391
-                    nullable = True,
392
-                    allowed_classes = [publication],
393
-                    group = editorial_group,
394
-                    back_reference = ('publication', 'linked_texts'),
395
-                    default = None
396
-)
397
-# Classe Issue
398
-issue = em.new_class( 'issue',
399
-                        display_name = 'Issue',
188
+                            abstract = False,
189
+                            parents = entitie,)
190
+publication.new_field(  'collection',
191
+                        display_name = 'Collection',
400 192
                         group = editorial_group,
401
-                        abstract = False,
402
-                        parents = publication)
403
-issue.new_field(    'isbn',
404
-                  display_name = 'ISBN',
405
-                  data_handler = 'varchar',
406
-                  group = editorial_group,
407
-)
408
-issue.new_field(    'print_isbn',
409
-                  display_name = {
410
-                    'eng': 'Printed ISBN',
411
-                    'fre': "ISBN imprimé",
412
-                  },
413
-                  data_handler = 'varchar',
414
-                  group = editorial_group,
415
-)
416
-issue.new_field(    'number',
417
-                    display_name = {
418
-                        'eng': 'Number',
419
-                        'fre': 'Numéro',
420
-                    },
421
-                  data_handler = 'varchar',
422
-                  group = editorial_group,
423
-)
424
-issue.new_field(    'cover',
425
-                    display_name = {
426
-                        'eng': 'Cover',
427
-                        'fre': 'Couverture',
428
-                    },
429
-                  data_handler = 'varchar',
430
-                  group = editorial_group,
431
-)
432
-issue.new_field(    'print_pub_date',
433
-                    display_name = {
434
-                        'eng': 'Print date',
435
-                        'fre': "Date d'impression",
436
-                    },
437
-                  data_handler = 'datetime',
438
-                  group = editorial_group,
439
-)     
440
-issue.new_field(    'e_pub_date',
441
-                    display_name = {
442
-                        'eng': 'Electronic publication date',
443
-                        'fre': 'Date de publication électronique',
444
-                    },
445
-                  data_handler = 'datetime',
446
-                  group = editorial_group,
447
-)  
448
-issue.new_field(    'abstract',
449
-                    display_name = {
450
-                        'eng': 'Abstract',
451
-                        'fre': 'Résumé',
452
-                    },
453
-                  data_handler = 'text',
454
-                  group = editorial_group,
455
-) 
456
-issue.new_field(    'collection',
457
-                    display_name = {
458
-                        'eng': 'Collection',
459
-                        'fre': 'Collection',
460
-                    },
461
-                    data_handler = 'link',
462
-                    nullable = True,
463
-                    allowed_classes = [collection],
193
+                        data_handler = 'link',
194
+                        default = None,
195
+                        nullable = True,
196
+                        allowed_classes = [collection],
197
+                        back_reference = ('collection', 'publications'))
198
+collection.new_field(   'publications',
199
+                        display_name = 'Publications',
200
+                        group = editorial_group,
201
+                        data_handler = 'list',
202
+                        allowed_classes = [publication],
203
+                        back_reference = ('publication', 'collection'))
204
+
205
+#########################
206
+#   Texte definition    #
207
+#########################
208
+
209
+section = em.new_class(    'section',
210
+                            display_name = 'Section',
211
+                            group = editorial_group,
212
+                            abstract = False,
213
+                            parents = text)
214
+
215
+subsection = em.new_class(  'subsection',
216
+                            display_name = 'Subsection',
217
+                            group = editorial_group,
218
+                            abstract = False,
219
+                            parents = section)
220
+
221
+section.new_field(  'childs',
222
+                    display_name = 'Next section',
464 223
                     group = editorial_group,
465
-                    back_reference = ('collection', 'linked_issues'),
466
-                    default = None
467
-)
468
-collection.new_field(   'linked_issues',
469
-                        display_name = {
470
-                        'eng': 'Linked issues',
471
-                        'fre': 'Numéros',
472
-                    },
473 224
                     data_handler = 'hierarch',
474
-                    back_reference = ('Issue', 'collection'),
475
-                    group = editorial_group,
476
-                    allowed_classes = [issue],
225
+                    allowed_classes = [subsection],
226
+                    back_reference = ('subsection', 'parent'),
477 227
                     default = None,
478 228
                     nullable = True)
479
-# Classe Part
480
-part = em.new_class(  'part',
481
-                            display_name = 'Part',
482
-                            group = editorial_group,
483
-                            abstract = False,
484
-                            parents = publication,)
485
-part.new_field(     'publication',
486
-                    display_name = {
487
-                        'eng': 'Publication',
488
-                        'fre': 'Publication',
489
-                    },
490
-                    data_handler = 'link',
491
-                    nullable = True,
492
-                    allowed_classes = [publication],
493
-                    group = editorial_group,
494
-                    back_reference = ('publication', 'linked_parts'),
495
-                    default = None
496
-)
497
-publication.new_field(  'linked_parts',
498
-                        display_name = {
499
-                            'eng': 'Parts',
500
-                            'fre': 'Parties',
501
-                        },
502
-                      data_handler = 'hierarch',
503
-                    nullable = True,
504
-                    allowed_classes = [part],
505
-                    group = editorial_group,
506
-                    back_reference = ('part', 'publication'),
507
-                    default = None
508
-)
229
+
230
+subsection.new_field(   'parent',
231
+                        display_name = 'Parent',
232
+                        group = editorial_group,
233
+                        data_handler = 'link',
234
+                        default = None,
235
+                        nullable = True,
236
+                        allowed_classes = [section],
237
+                        back_reference = ('section', 'childs'))
509 238
 
510 239
 #####################
511 240
 # Persons & authors #
@@ -514,8 +243,8 @@ publication.new_field(  'linked_parts',
514 243
 editorial_person_group = em.new_group(  'editorial_person',
515 244
                                         display_name = 'Editorial person',
516 245
                                         help_text = {
517
-                                            'eng': 'Introduce the concept of editorial person (author, translator, director)',
518
-                                            'fre': 'Contient les classes servant à la gestion des personnes éditoriales (auteur, traducteur, directeur...)',
246
+                                            'eng': 'Introduce the concept of editorial person (authors, translator etc)',
247
+                                            'fre': 'Contient les classes servant à la gestion des personnes editorials (auteurs, traducteur...)',
519 248
                                         },
520 249
                                         depends = (editorial_group,)
521 250
 )
@@ -608,7 +337,7 @@ index_name = index_abstract.new_field(
608 337
     display_name = {
609 338
         'eng': 'name',
610 339
         'fre': 'nom'},
611
-    data_handler = 'text',
340
+    data_handler = 'varchar',
612 341
     group = index_group)
613 342
 
614 343
 index_value = index_abstract.new_field(

Loading…
Cancel
Save