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
 em_test: em_test.py
43
 em_test: em_test.py
44
 	$(python) em_test.py
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
 # generate leapi dynamic code
50
 # generate leapi dynamic code
47
-dyncode: examples/em_test.pickle
51
+dyncode: examples/em_test.pickle 
48
 	$(python) scripts/refreshdyn.py examples/em_test.pickle $(dyncode_filename) && echo -e "\n\nCode generated in $(dyncode_filename)"
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
 # run tests
57
 # run tests
51
 checks: runtest
58
 checks: runtest
52
 	./runtest -v
59
 	./runtest -v

+ 90
- 361
em_test.py View File

42
                         data_handler = 'uniqid',
42
                         data_handler = 'uniqid',
43
                         internal = True,
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
 em_object.new_field(    'date_create',
53
 em_object.new_field(    'date_create',
46
                         display_name = 'Creation date',
54
                         display_name = 'Creation date',
47
                         group = base_group,
55
                         group = base_group,
56
                         now_on_update = True,
64
                         now_on_update = True,
57
                         internal = True,
65
                         internal = True,
58
 )
66
 )
67
+
68
+########################
69
+# Lodel old classtypes #
70
+########################
59
 entitie = em.new_class( 'entitie',
71
 entitie = em.new_class( 'entitie',
60
                         display_name = 'entitie',
72
                         display_name = 'entitie',
61
                         help_text = 'Replace old entity classtype',
73
                         help_text = 'Replace old entity classtype',
63
                         group = base_group,
75
                         group = base_group,
64
                         parents = em_object,
76
                         parents = em_object,
65
 )
77
 )
66
-########################
67
-# Base group
68
-########################
69
 
78
 
70
 person = em.new_class(  'person',
79
 person = em.new_class(  'person',
71
                         display_name = 'Person',
80
                         display_name = 'Person',
72
-                        help_text = 'Person type',
81
+                        help_text = 'Replace old person classtype',
73
                         abstract = False,
82
                         abstract = False,
74
                         group = base_group,
83
                         group = base_group,
75
                         parents = em_object,
84
                         parents = em_object,
91
                     data_handler = 'varchar',
100
                     data_handler = 'varchar',
92
                     group = base_group,
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
                     display_name = {
104
                     display_name = {
113
-                        'eng': 'Name',
114
-                        'fre': 'Nom',
105
+                        'eng': 'Fullname',
106
+                        'fre': 'Nom complet',
115
                     },
107
                     },
116
-                    data_handler = 'varchar',
117
                     group = base_group,
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
                     group = base_group,
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
                                 depends = (base_group,)
145
                                 depends = (base_group,)
148
 )
146
 )
149
 
147
 
150
-################################### Texts ##########################################################
151
 # Classe texte
148
 # Classe texte
152
 text = em.new_class(   'text',
149
 text = em.new_class(   'text',
153
                         display_name = 'Text',
150
                         display_name = 'Text',
160
 text.new_field(    'title',
157
 text.new_field(    'title',
161
                     display_name = {'eng': 'Title', 'fre': 'Titre'},
158
                     display_name = {'eng': 'Title', 'fre': 'Titre'},
162
                     group = editorial_group,
159
                     group = editorial_group,
163
-                    data_handler = 'text',
160
+                    data_handler = 'varchar',
164
                     nullable = True,)
161
                     nullable = True,)
165
 text.new_field(    'subtitle',
162
 text.new_field(    'subtitle',
166
                     display_name = {
163
                     display_name = {
168
                         'fre': 'Sous-titre',
165
                         'fre': 'Sous-titre',
169
                     },
166
                     },
170
                     group = editorial_group,
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
                     data_handler = 'varchar',
168
                     data_handler = 'varchar',
181
                     nullable = True,
169
                     nullable = True,
182
                     default = None)
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
                             group = editorial_group,
175
                             group = editorial_group,
292
-                            abstract = True,
176
+                            abstract = False,
293
                             parents = entitie)
177
                             parents = entitie)
294
-container.new_field(   'title',
178
+collection.new_field(   'title',
295
                         display_name = 'Title',
179
                         display_name = 'Title',
296
                         group = editorial_group,
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
                         data_handler = 'varchar'
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
 publication = em.new_class(  'publication',
185
 publication = em.new_class(  'publication',
369
                             display_name = 'Publication',
186
                             display_name = 'Publication',
370
                             group = editorial_group,
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
                         group = editorial_group,
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
                     group = editorial_group,
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
                     data_handler = 'hierarch',
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
                     default = None,
227
                     default = None,
478
                     nullable = True)
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
 # Persons & authors #
240
 # Persons & authors #
514
 editorial_person_group = em.new_group(  'editorial_person',
243
 editorial_person_group = em.new_group(  'editorial_person',
515
                                         display_name = 'Editorial person',
244
                                         display_name = 'Editorial person',
516
                                         help_text = {
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
                                         depends = (editorial_group,)
249
                                         depends = (editorial_group,)
521
 )
250
 )
608
     display_name = {
337
     display_name = {
609
         'eng': 'name',
338
         'eng': 'name',
610
         'fre': 'nom'},
339
         'fre': 'nom'},
611
-    data_handler = 'text',
340
+    data_handler = 'varchar',
612
     group = index_group)
341
     group = index_group)
613
 
342
 
614
 index_value = index_abstract.new_field(
343
 index_value = index_abstract.new_field(

Loading…
Cancel
Save