|
@@ -0,0 +1,697 @@
|
|
1
|
+#!/usr/bin/python3
|
|
2
|
+#-*- coding: utf-8 -*-
|
|
3
|
+import sys
|
|
4
|
+import os, os.path
|
|
5
|
+
|
|
6
|
+sys.path.append(os.path.dirname(os.getcwd()+'/..'))
|
|
7
|
+from lodel.context import LodelContext
|
|
8
|
+LodelContext.init()
|
|
9
|
+
|
|
10
|
+from lodel.settings.settings import Settings as settings
|
|
11
|
+settings('globconf.d')
|
|
12
|
+from lodel.settings import Settings
|
|
13
|
+
|
|
14
|
+from lodel.editorial_model.components import *
|
|
15
|
+from lodel.editorial_model.exceptions import *
|
|
16
|
+from lodel.editorial_model.model import EditorialModel
|
|
17
|
+
|
|
18
|
+em = EditorialModel('simpleem', 'Simple editorial model')
|
|
19
|
+
|
|
20
|
+base_group = em.new_group( 'base_group',
|
|
21
|
+ display_name = 'Base group',
|
|
22
|
+ help_text = 'Base group that implements base EM features (like classtype)'
|
|
23
|
+)
|
|
24
|
+
|
|
25
|
+####################
|
|
26
|
+# Lodel Object #
|
|
27
|
+####################
|
|
28
|
+em_abstract = em.new_class( 'abstract_object',
|
|
29
|
+ display_name = 'Abstract lodel object',
|
|
30
|
+ help_text = 'For testing purpose',
|
|
31
|
+ group = base_group,
|
|
32
|
+ abstract = True)
|
|
33
|
+
|
|
34
|
+em_object = em.new_class( 'object',
|
|
35
|
+ display_name = 'Object',
|
|
36
|
+ help_text = 'Main class for all Em objects',
|
|
37
|
+ group = base_group,
|
|
38
|
+ abstract = True,
|
|
39
|
+ parents = em_abstract,
|
|
40
|
+)
|
|
41
|
+em_object.new_field( 'lodel_id',
|
|
42
|
+ display_name = 'Lodel identifier',
|
|
43
|
+ help_text = 'Uniq ID that identify every lodel object',
|
|
44
|
+ group = base_group,
|
|
45
|
+ data_handler = 'uniqid',
|
|
46
|
+ internal = True,
|
|
47
|
+)
|
|
48
|
+em_object.new_field( 'date_create',
|
|
49
|
+ display_name = 'Creation date',
|
|
50
|
+ group = base_group,
|
|
51
|
+ data_handler = 'datetime',
|
|
52
|
+ now_on_create = True,
|
|
53
|
+ internal = True,
|
|
54
|
+)
|
|
55
|
+em_object.new_field( 'date_update',
|
|
56
|
+ display_name = 'Last update',
|
|
57
|
+ group = base_group,
|
|
58
|
+ data_handler = 'datetime',
|
|
59
|
+ now_on_update = True,
|
|
60
|
+ internal = True,
|
|
61
|
+)
|
|
62
|
+entitie = em.new_class( 'entitie',
|
|
63
|
+ display_name = 'entitie',
|
|
64
|
+ help_text = 'Replace old entity classtype',
|
|
65
|
+ abstract = True,
|
|
66
|
+ group = base_group,
|
|
67
|
+ parents = em_object,
|
|
68
|
+)
|
|
69
|
+########################
|
|
70
|
+# Base group
|
|
71
|
+########################
|
|
72
|
+
|
|
73
|
+person = em.new_class( 'person',
|
|
74
|
+ display_name = 'Person',
|
|
75
|
+ help_text = 'Person type',
|
|
76
|
+ abstract = False,
|
|
77
|
+ group = base_group,
|
|
78
|
+ parents = em_object,
|
|
79
|
+)
|
|
80
|
+
|
|
81
|
+person.new_field( 'firstname',
|
|
82
|
+ display_name = {
|
|
83
|
+ 'eng': 'Firstname',
|
|
84
|
+ 'fre': 'Prénom',
|
|
85
|
+ },
|
|
86
|
+ data_handler = 'varchar',
|
|
87
|
+ group = base_group,
|
|
88
|
+)
|
|
89
|
+person.new_field( 'lastname',
|
|
90
|
+ display_name = {
|
|
91
|
+ 'eng': 'Lastname',
|
|
92
|
+ 'fre': 'Nom de famille',
|
|
93
|
+ },
|
|
94
|
+ data_handler = 'varchar',
|
|
95
|
+ group = base_group,
|
|
96
|
+)
|
|
97
|
+
|
|
98
|
+# person.new_field( 'role',
|
|
99
|
+# display_name = {
|
|
100
|
+# 'eng': 'Role',
|
|
101
|
+# 'fre': 'Rôle',
|
|
102
|
+# },
|
|
103
|
+# data_handler = 'varchar',
|
|
104
|
+# group = base_group,
|
|
105
|
+# )
|
|
106
|
+
|
|
107
|
+entry = em.new_class( 'entry',
|
|
108
|
+ display_name = 'Entry',
|
|
109
|
+ help_text = 'Entry type',
|
|
110
|
+ abstract = False,
|
|
111
|
+ group = base_group,
|
|
112
|
+ parents = em_object,
|
|
113
|
+)
|
|
114
|
+entry.new_field( 'name',
|
|
115
|
+ display_name = {
|
|
116
|
+ 'eng': 'Name',
|
|
117
|
+ 'fre': 'Nom',
|
|
118
|
+ },
|
|
119
|
+ data_handler = 'varchar',
|
|
120
|
+ group = base_group,
|
|
121
|
+)
|
|
122
|
+entry.new_field( 'description',
|
|
123
|
+ display_name = {
|
|
124
|
+ 'eng': 'Description',
|
|
125
|
+ 'fre': 'Description',
|
|
126
|
+ },
|
|
127
|
+ data_handler = 'text',
|
|
128
|
+ group = base_group,
|
|
129
|
+)
|
|
130
|
+
|
|
131
|
+entry.new_field( 'role',
|
|
132
|
+ display_name = {
|
|
133
|
+ 'eng': 'Role',
|
|
134
|
+ 'fre': 'Rôle',
|
|
135
|
+ },
|
|
136
|
+ data_handler = 'varchar',
|
|
137
|
+ group = base_group,
|
|
138
|
+)
|
|
139
|
+
|
|
140
|
+#####################
|
|
141
|
+# Editorial classes #
|
|
142
|
+#####################
|
|
143
|
+
|
|
144
|
+editorial_group = em.new_group( 'editorial_abstract',
|
|
145
|
+ display_name = 'Editorial base',
|
|
146
|
+ help_text = {
|
|
147
|
+ 'eng': 'Contains abstract class to handler editorial contents',
|
|
148
|
+ 'fre': 'Contient les classes abstraites permetant la gestion de contenu éditorial'
|
|
149
|
+ },
|
|
150
|
+ depends = (base_group,)
|
|
151
|
+)
|
|
152
|
+
|
|
153
|
+################################### Texts ##########################################################
|
|
154
|
+# Classe texte
|
|
155
|
+text = em.new_class( 'text',
|
|
156
|
+ display_name = 'Text',
|
|
157
|
+ help_text = 'Abstract class that represent texts',
|
|
158
|
+ group = editorial_group,
|
|
159
|
+ abstract = True,
|
|
160
|
+ parents = entitie,
|
|
161
|
+)
|
|
162
|
+
|
|
163
|
+text.new_field( 'title',
|
|
164
|
+ display_name = {'eng': 'Title', 'fre': 'Titre'},
|
|
165
|
+ group = editorial_group,
|
|
166
|
+ data_handler = 'text',
|
|
167
|
+ nullable = True,)
|
|
168
|
+text.new_field( 'subtitle',
|
|
169
|
+ display_name = {
|
|
170
|
+ 'eng': 'Subtitle',
|
|
171
|
+ 'fre': 'Sous-titre',
|
|
172
|
+ },
|
|
173
|
+ group = editorial_group,
|
|
174
|
+ data_handler = 'text',
|
|
175
|
+ nullable = True,
|
|
176
|
+ default = None)
|
|
177
|
+text.new_field( 'language',
|
|
178
|
+ display_name = {
|
|
179
|
+ 'eng': 'Language',
|
|
180
|
+ 'fre': 'Langue',
|
|
181
|
+ },
|
|
182
|
+ group = editorial_group,
|
|
183
|
+ data_handler = 'varchar',
|
|
184
|
+ nullable = True,
|
|
185
|
+ default = None)
|
|
186
|
+text.new_field( 'text',
|
|
187
|
+ display_name = {
|
|
188
|
+ 'eng': 'Text',
|
|
189
|
+ 'fre': 'Texte',
|
|
190
|
+ },
|
|
191
|
+ group = editorial_group,
|
|
192
|
+ data_handler = 'text',
|
|
193
|
+ nullable = True,
|
|
194
|
+ default = None)
|
|
195
|
+text.new_field( 'pub_date',
|
|
196
|
+ display_name = {
|
|
197
|
+ 'eng': 'Publication date',
|
|
198
|
+ 'fre': 'Date de publication',
|
|
199
|
+ },
|
|
200
|
+ group = editorial_group,
|
|
201
|
+ data_handler = 'datetime',
|
|
202
|
+ nullable = True,
|
|
203
|
+ default = None)
|
|
204
|
+text.new_field( 'footnotes',
|
|
205
|
+ display_name = {
|
|
206
|
+ 'eng': 'Footnotes',
|
|
207
|
+ 'fre': 'Notes de bas de page',
|
|
208
|
+ },
|
|
209
|
+ group = editorial_group,
|
|
210
|
+ data_handler = 'text',
|
|
211
|
+ nullable = True,
|
|
212
|
+ default = None)
|
|
213
|
+text.new_field( 'linked_entries',
|
|
214
|
+ display_name = {
|
|
215
|
+ 'eng': 'Related entries',
|
|
216
|
+ 'fre': 'Indices liés',
|
|
217
|
+ },
|
|
218
|
+ group = editorial_group,
|
|
219
|
+ data_handler = 'list',
|
|
220
|
+ nullable = True,
|
|
221
|
+ allowed_classes = [entry],
|
|
222
|
+ back_reference = ('entry', 'linked_texts'),
|
|
223
|
+ default = None
|
|
224
|
+)
|
|
225
|
+entry.new_field( 'linked_texts',
|
|
226
|
+ display_name = {
|
|
227
|
+ 'eng': 'Related text',
|
|
228
|
+ 'fre': 'Texte lié ',
|
|
229
|
+ },
|
|
230
|
+ data_handler = 'list',
|
|
231
|
+ nullable = True,
|
|
232
|
+ allowed_classes = [text],
|
|
233
|
+ group = editorial_group,
|
|
234
|
+ back_reference = ('text', 'linked_entries'),
|
|
235
|
+ default = None
|
|
236
|
+)
|
|
237
|
+# Classe article
|
|
238
|
+article = em.new_class( 'article',
|
|
239
|
+ display_name = 'Article',
|
|
240
|
+ group = editorial_group,
|
|
241
|
+ abstract = False,
|
|
242
|
+ parents = text)
|
|
243
|
+article.new_field( 'abstract',
|
|
244
|
+ display_name = {
|
|
245
|
+ 'eng': 'Abstract',
|
|
246
|
+ 'fre': 'Résumé',
|
|
247
|
+ },
|
|
248
|
+ group = editorial_group,
|
|
249
|
+ data_handler = 'text'
|
|
250
|
+)
|
|
251
|
+article.new_field( 'appendix',
|
|
252
|
+ display_name = {
|
|
253
|
+ 'eng': 'Appendix',
|
|
254
|
+ 'fre': 'Appendice',
|
|
255
|
+ },
|
|
256
|
+ group = editorial_group,
|
|
257
|
+ data_handler = 'text'
|
|
258
|
+)
|
|
259
|
+article.new_field( 'bibliography',
|
|
260
|
+ display_name = {
|
|
261
|
+ 'eng': 'Bibliography',
|
|
262
|
+ 'fre': 'Bibliographie',
|
|
263
|
+ },
|
|
264
|
+ group = editorial_group,
|
|
265
|
+ data_handler = 'text'
|
|
266
|
+)
|
|
267
|
+article.new_field( 'author_note',
|
|
268
|
+ display_name = {
|
|
269
|
+ 'eng': 'Author note',
|
|
270
|
+ 'fre': "Note de l'auteur",
|
|
271
|
+ },
|
|
272
|
+ group = editorial_group,
|
|
273
|
+ data_handler = 'text'
|
|
274
|
+)
|
|
275
|
+# Classe Review
|
|
276
|
+review = em.new_class( 'review',
|
|
277
|
+ display_name = 'Review',
|
|
278
|
+ group = editorial_group,
|
|
279
|
+ abstract = False,
|
|
280
|
+ parents = text)
|
|
281
|
+review.new_field( 'reference',
|
|
282
|
+ display_name = {
|
|
283
|
+ 'eng': 'Reference',
|
|
284
|
+ 'fre': "Référence",
|
|
285
|
+ },
|
|
286
|
+ group = editorial_group,
|
|
287
|
+ data_handler = 'text'
|
|
288
|
+)
|
|
289
|
+
|
|
290
|
+###################################### Containers ###########################################
|
|
291
|
+# Classe container
|
|
292
|
+container = em.new_class( 'container',
|
|
293
|
+ display_name = 'Container',
|
|
294
|
+ group = editorial_group,
|
|
295
|
+ abstract = True,
|
|
296
|
+ parents = entitie)
|
|
297
|
+container.new_field( 'title',
|
|
298
|
+ display_name = 'Title',
|
|
299
|
+ group = editorial_group,
|
|
300
|
+ data_handler = 'text'
|
|
301
|
+)
|
|
302
|
+container.new_field( 'subtitle',
|
|
303
|
+ display_name = 'Subtitle',
|
|
304
|
+ group = editorial_group,
|
|
305
|
+ data_handler = 'text'
|
|
306
|
+)
|
|
307
|
+container.new_field( 'language',
|
|
308
|
+ display_name = {
|
|
309
|
+ 'eng' : 'Language',
|
|
310
|
+ 'fre' : 'Langue',
|
|
311
|
+ },
|
|
312
|
+ group = editorial_group,
|
|
313
|
+ data_handler = 'varchar'
|
|
314
|
+)
|
|
315
|
+container.new_field( 'linked_directors',
|
|
316
|
+ display_name = {
|
|
317
|
+ 'eng': 'Directors',
|
|
318
|
+ 'fre': 'Directeurs',
|
|
319
|
+ },
|
|
320
|
+ group = editorial_group,
|
|
321
|
+ data_handler = 'list',
|
|
322
|
+ nullable = True,
|
|
323
|
+ allowed_classes = [person],
|
|
324
|
+ back_reference = ('person', 'linked_containers'),
|
|
325
|
+ default = None
|
|
326
|
+)
|
|
327
|
+person.new_field( 'linked_containers',
|
|
328
|
+ display_name = {
|
|
329
|
+ 'eng': 'Director of ',
|
|
330
|
+ 'fre': 'Directeur de ',
|
|
331
|
+ },
|
|
332
|
+ group = editorial_group,
|
|
333
|
+ data_handler = 'list',
|
|
334
|
+ nullable = True,
|
|
335
|
+ allowed_classes = [container],
|
|
336
|
+ back_reference = ('container', 'linked_directors'),
|
|
337
|
+ default = None
|
|
338
|
+)
|
|
339
|
+container.new_field( 'description',
|
|
340
|
+ display_name = {
|
|
341
|
+ 'eng': 'Description',
|
|
342
|
+ 'fre': 'Description',
|
|
343
|
+ },
|
|
344
|
+ data_handler = 'text',
|
|
345
|
+ group = editorial_group,
|
|
346
|
+)
|
|
347
|
+container.new_field( 'publisher_note',
|
|
348
|
+ display_name = {
|
|
349
|
+ 'eng': 'Publisher note',
|
|
350
|
+ 'fre': "Note de l'éditeur",
|
|
351
|
+ },
|
|
352
|
+ data_handler = 'text',
|
|
353
|
+ group = editorial_group,
|
|
354
|
+)
|
|
355
|
+
|
|
356
|
+# Classe collection
|
|
357
|
+collection = em.new_class( 'collection',
|
|
358
|
+ display_name = 'Collection',
|
|
359
|
+ group = editorial_group,
|
|
360
|
+ abstract = False,
|
|
361
|
+ parents = container)
|
|
362
|
+collection.new_field( 'issn',
|
|
363
|
+ display_name = {
|
|
364
|
+ 'eng': 'ISSN',
|
|
365
|
+ 'fre': "ISSN",
|
|
366
|
+ },
|
|
367
|
+ data_handler = 'varchar',
|
|
368
|
+ group = editorial_group,
|
|
369
|
+)
|
|
370
|
+# Classe Publication : Pour gérer les back_references vers issue ou part
|
|
371
|
+publication = em.new_class( 'publication',
|
|
372
|
+ display_name = 'Publication',
|
|
373
|
+ group = editorial_group,
|
|
374
|
+ abstract = True,
|
|
375
|
+ parents = container)
|
|
376
|
+publication.new_field( 'linked_texts',
|
|
377
|
+ display_name = {
|
|
378
|
+ 'eng': 'Text',
|
|
379
|
+ 'fre': 'Texte',
|
|
380
|
+ },
|
|
381
|
+ data_handler = 'list',
|
|
382
|
+ nullable = True,
|
|
383
|
+ allowed_classes = [text],
|
|
384
|
+ group = editorial_group,
|
|
385
|
+ back_reference = ('text', 'linked_container'),
|
|
386
|
+ default = None
|
|
387
|
+)
|
|
388
|
+text.new_field( 'linked_container',
|
|
389
|
+ display_name = {
|
|
390
|
+ 'eng': 'Container',
|
|
391
|
+ 'fre': 'Conteneur',
|
|
392
|
+ },
|
|
393
|
+ data_handler = 'link',
|
|
394
|
+ nullable = True,
|
|
395
|
+ allowed_classes = [publication],
|
|
396
|
+ group = editorial_group,
|
|
397
|
+ back_reference = ('publication', 'linked_texts'),
|
|
398
|
+ default = None
|
|
399
|
+)
|
|
400
|
+# Classe Issue
|
|
401
|
+issue = em.new_class( 'issue',
|
|
402
|
+ display_name = 'Issue',
|
|
403
|
+ group = editorial_group,
|
|
404
|
+ abstract = False,
|
|
405
|
+ parents = publication)
|
|
406
|
+issue.new_field( 'isbn',
|
|
407
|
+ display_name = 'ISBN',
|
|
408
|
+ data_handler = 'varchar',
|
|
409
|
+ group = editorial_group,
|
|
410
|
+)
|
|
411
|
+issue.new_field( 'print_isbn',
|
|
412
|
+ display_name = {
|
|
413
|
+ 'eng': 'Printed ISBN',
|
|
414
|
+ 'fre': "ISBN imprimé",
|
|
415
|
+ },
|
|
416
|
+ data_handler = 'varchar',
|
|
417
|
+ group = editorial_group,
|
|
418
|
+)
|
|
419
|
+issue.new_field( 'number',
|
|
420
|
+ display_name = {
|
|
421
|
+ 'eng': 'Number',
|
|
422
|
+ 'fre': 'Numéro',
|
|
423
|
+ },
|
|
424
|
+ data_handler = 'varchar',
|
|
425
|
+ group = editorial_group,
|
|
426
|
+)
|
|
427
|
+issue.new_field( 'cover',
|
|
428
|
+ display_name = {
|
|
429
|
+ 'eng': 'Cover',
|
|
430
|
+ 'fre': 'Couverture',
|
|
431
|
+ },
|
|
432
|
+ data_handler = 'varchar',
|
|
433
|
+ group = editorial_group,
|
|
434
|
+)
|
|
435
|
+issue.new_field( 'print_pub_date',
|
|
436
|
+ display_name = {
|
|
437
|
+ 'eng': 'Print date',
|
|
438
|
+ 'fre': "Date d'impression",
|
|
439
|
+ },
|
|
440
|
+ data_handler = 'datetime',
|
|
441
|
+ group = editorial_group,
|
|
442
|
+)
|
|
443
|
+issue.new_field( 'e_pub_date',
|
|
444
|
+ display_name = {
|
|
445
|
+ 'eng': 'Electronic publication date',
|
|
446
|
+ 'fre': 'Date de publication électronique',
|
|
447
|
+ },
|
|
448
|
+ data_handler = 'datetime',
|
|
449
|
+ group = editorial_group,
|
|
450
|
+)
|
|
451
|
+issue.new_field( 'abstract',
|
|
452
|
+ display_name = {
|
|
453
|
+ 'eng': 'Abstract',
|
|
454
|
+ 'fre': 'Résumé',
|
|
455
|
+ },
|
|
456
|
+ data_handler = 'text',
|
|
457
|
+ group = editorial_group,
|
|
458
|
+)
|
|
459
|
+issue.new_field( 'collection',
|
|
460
|
+ display_name = {
|
|
461
|
+ 'eng': 'Collection',
|
|
462
|
+ 'fre': 'Collection',
|
|
463
|
+ },
|
|
464
|
+ data_handler = 'link',
|
|
465
|
+ nullable = True,
|
|
466
|
+ allowed_classes = [collection],
|
|
467
|
+ group = editorial_group,
|
|
468
|
+ back_reference = ('collection', 'linked_issues'),
|
|
469
|
+ default = None
|
|
470
|
+)
|
|
471
|
+collection.new_field( 'linked_issues',
|
|
472
|
+ display_name = {
|
|
473
|
+ 'eng': 'Linked issues',
|
|
474
|
+ 'fre': 'Numéros',
|
|
475
|
+ },
|
|
476
|
+ data_handler = 'hierarch',
|
|
477
|
+ back_reference = ('Issue', 'collection'),
|
|
478
|
+ group = editorial_group,
|
|
479
|
+ allowed_classes = [issue],
|
|
480
|
+ default = None,
|
|
481
|
+ nullable = True)
|
|
482
|
+# Classe Part
|
|
483
|
+part = em.new_class( 'part',
|
|
484
|
+ display_name = 'Part',
|
|
485
|
+ group = editorial_group,
|
|
486
|
+ abstract = False,
|
|
487
|
+ parents = publication,)
|
|
488
|
+part.new_field( 'publication',
|
|
489
|
+ display_name = {
|
|
490
|
+ 'eng': 'Publication',
|
|
491
|
+ 'fre': 'Publication',
|
|
492
|
+ },
|
|
493
|
+ data_handler = 'link',
|
|
494
|
+ nullable = True,
|
|
495
|
+ allowed_classes = [publication],
|
|
496
|
+ group = editorial_group,
|
|
497
|
+ back_reference = ('publication', 'linked_parts'),
|
|
498
|
+ default = None
|
|
499
|
+)
|
|
500
|
+publication.new_field( 'linked_parts',
|
|
501
|
+ display_name = {
|
|
502
|
+ 'eng': 'Parts',
|
|
503
|
+ 'fre': 'Parties',
|
|
504
|
+ },
|
|
505
|
+ data_handler = 'hierarch',
|
|
506
|
+ nullable = True,
|
|
507
|
+ allowed_classes = [part],
|
|
508
|
+ group = editorial_group,
|
|
509
|
+ back_reference = ('part', 'publication'),
|
|
510
|
+ default = None
|
|
511
|
+)
|
|
512
|
+
|
|
513
|
+#####################
|
|
514
|
+# Persons & authors #
|
|
515
|
+#####################
|
|
516
|
+
|
|
517
|
+editorial_person_group = em.new_group( 'editorial_person',
|
|
518
|
+ display_name = 'Editorial person',
|
|
519
|
+ help_text = {
|
|
520
|
+ 'eng': 'Introduce the concept of editorial person (author, translator, director)',
|
|
521
|
+ 'fre': 'Contient les classes servant à la gestion des personnes éditoriales (auteur, traducteur, directeur...)',
|
|
522
|
+ },
|
|
523
|
+ depends = (editorial_group,)
|
|
524
|
+)
|
|
525
|
+text_person = em.new_class( 'text_person',
|
|
526
|
+ display_name = {
|
|
527
|
+ 'eng': 'TextPerson',
|
|
528
|
+ 'fre': 'TextePersonne',
|
|
529
|
+ },
|
|
530
|
+ help_text = {
|
|
531
|
+ 'eng': 'Represent a link between someone and a text',
|
|
532
|
+ 'fre': 'Représente un lien entre une personne et un texte',
|
|
533
|
+ },
|
|
534
|
+ group = editorial_person_group,
|
|
535
|
+ abstract = True,
|
|
536
|
+ parents = entitie,
|
|
537
|
+)
|
|
538
|
+bref_textperson_text = text_person.new_field( 'text',
|
|
539
|
+ display_name = {
|
|
540
|
+ 'eng': 'Linked text',
|
|
541
|
+ 'fre': 'Texte lié',
|
|
542
|
+ },
|
|
543
|
+ data_handler = 'link',
|
|
544
|
+ allowed_classes = [text],
|
|
545
|
+ group = editorial_person_group
|
|
546
|
+)
|
|
547
|
+bref_textperson_person = text_person.new_field( 'person',
|
|
548
|
+ display_name = {
|
|
549
|
+ 'eng': 'Linked person',
|
|
550
|
+ 'fre': 'Personne liée',
|
|
551
|
+ },
|
|
552
|
+ data_handler = 'link',
|
|
553
|
+ allowed_classes = [person],
|
|
554
|
+ group = editorial_person_group,
|
|
555
|
+)
|
|
556
|
+text_person.new_field( 'role',
|
|
557
|
+ display_name = {
|
|
558
|
+ 'eng': 'Person role',
|
|
559
|
+ 'fre': 'Role de la personne',
|
|
560
|
+ },
|
|
561
|
+ data_handler = 'varchar',
|
|
562
|
+ group = editorial_person_group
|
|
563
|
+)
|
|
564
|
+
|
|
565
|
+# simple example of linked text / person
|
|
566
|
+person.new_field( 'linked_texts',
|
|
567
|
+ display_name = {
|
|
568
|
+ 'eng': 'Linked texts',
|
|
569
|
+ 'fre': 'Textes liés',
|
|
570
|
+ },
|
|
571
|
+ data_handler = 'list',
|
|
572
|
+ back_reference = ('Text', 'linked_persons'),
|
|
573
|
+ group = editorial_person_group,
|
|
574
|
+ allowed_classes = [text],
|
|
575
|
+ default = None,
|
|
576
|
+ nullable = True)
|
|
577
|
+
|
|
578
|
+text.new_field( 'linked_persons',
|
|
579
|
+ display_name = {
|
|
580
|
+ 'eng': 'Linked persons',
|
|
581
|
+ 'fre': 'Personnes liées',
|
|
582
|
+ },
|
|
583
|
+ data_handler = 'list',
|
|
584
|
+ back_reference = ('Person', 'linked_texts'),
|
|
585
|
+ group = editorial_person_group,
|
|
586
|
+ allowed_classes = [person],
|
|
587
|
+ default = None,
|
|
588
|
+ nullable = True)
|
|
589
|
+
|
|
590
|
+#####################
|
|
591
|
+# Index classes # <--- Note : using a different datasource for testing
|
|
592
|
+##################### purpose
|
|
593
|
+
|
|
594
|
+index_group = em.new_group( 'index_group',
|
|
595
|
+ display_name = 'Indexes',
|
|
596
|
+ help_text = {
|
|
597
|
+ 'eng': 'EM class that represents indexes'},
|
|
598
|
+ depends = (editorial_group,))
|
|
599
|
+
|
|
600
|
+index_abstract = em.new_class(
|
|
601
|
+ 'indexAbs',
|
|
602
|
+ display_name = {'eng': 'Abstract Index'},
|
|
603
|
+ help_text = {'eng': 'Abstract class common to each Index classes'},
|
|
604
|
+ abstract = True,
|
|
605
|
+ group = index_group,
|
|
606
|
+ datasources = 'dummy2',
|
|
607
|
+ parents = em_object)
|
|
608
|
+
|
|
609
|
+index_name = index_abstract.new_field(
|
|
610
|
+ 'name',
|
|
611
|
+ display_name = {
|
|
612
|
+ 'eng': 'name',
|
|
613
|
+ 'fre': 'nom'},
|
|
614
|
+ data_handler = 'text',
|
|
615
|
+ group = index_group)
|
|
616
|
+
|
|
617
|
+index_value = index_abstract.new_field(
|
|
618
|
+ 'value',
|
|
619
|
+ display_name = {
|
|
620
|
+ 'eng': 'value',
|
|
621
|
+ 'fre': 'valeur'},
|
|
622
|
+ data_handler = 'varchar',
|
|
623
|
+ group = index_group)
|
|
624
|
+
|
|
625
|
+text.new_field( 'indexes',
|
|
626
|
+ display_name = {
|
|
627
|
+ 'eng': 'Indexes',
|
|
628
|
+ 'fre': 'Indexes'},
|
|
629
|
+ data_handler = 'list',
|
|
630
|
+ back_reference = ('Indexabs', 'texts'),
|
|
631
|
+ allowed_classes = [index_abstract],
|
|
632
|
+ default = None,
|
|
633
|
+ nullable = True,
|
|
634
|
+ group = index_group)
|
|
635
|
+
|
|
636
|
+index_abstract.new_field( 'texts',
|
|
637
|
+ display_name = {
|
|
638
|
+ 'eng': 'Text referenced by this index',
|
|
639
|
+ 'fre': 'Texte contenant cette index'},
|
|
640
|
+ data_handler = 'list',
|
|
641
|
+ back_reference = ('Text', 'indexes'),
|
|
642
|
+ allowed_classes = [text],
|
|
643
|
+ group = index_group)
|
|
644
|
+
|
|
645
|
+index_theme = em.new_class(
|
|
646
|
+ 'indexTheme',
|
|
647
|
+ display_name = {
|
|
648
|
+ 'eng': 'Thematic index',
|
|
649
|
+ 'fre': 'Index thématique'},
|
|
650
|
+ group = index_group,
|
|
651
|
+ datasources = 'dummy2',
|
|
652
|
+ parents = index_abstract)
|
|
653
|
+
|
|
654
|
+index_theme_theme = index_abstract.new_field(
|
|
655
|
+ 'theme',
|
|
656
|
+ display_name = {
|
|
657
|
+ 'eng': 'theme'},
|
|
658
|
+ data_handler = 'varchar',
|
|
659
|
+ group = index_group)
|
|
660
|
+
|
|
661
|
+#############
|
|
662
|
+# USERS #
|
|
663
|
+#############
|
|
664
|
+
|
|
665
|
+user_group = em.new_group(
|
|
666
|
+ 'users', display_name = 'Lodel users',
|
|
667
|
+ help_text = 'Group that handle users en perm')
|
|
668
|
+
|
|
669
|
+user = em.new_class(
|
|
670
|
+ 'user', display_name = 'Lodel user', help_text = 'Represent a lodel user',
|
|
671
|
+ group = user_group, abstract = False)
|
|
672
|
+
|
|
673
|
+user.new_field(
|
|
674
|
+ 'id', display_name = 'user identifier', help_text = 'Uniq ID',
|
|
675
|
+ group = user_group, data_handler = 'uniqid', internal = True)
|
|
676
|
+
|
|
677
|
+user.new_field(
|
|
678
|
+ 'firstname', display_name = 'Firstname',
|
|
679
|
+ group = user_group, data_handler = 'varchar', internal = False)
|
|
680
|
+
|
|
681
|
+user.new_field(
|
|
682
|
+ 'lastname', display_name = 'Lastname',
|
|
683
|
+ group = user_group, data_handler = 'varchar', internal = False)
|
|
684
|
+
|
|
685
|
+user.new_field(
|
|
686
|
+ 'login', display_name = 'user login', help_text = 'login',
|
|
687
|
+ group = user_group, data_handler = 'varchar', uniq = True, internal = False)
|
|
688
|
+
|
|
689
|
+user.new_field(
|
|
690
|
+ 'password', display_name = 'Password',
|
|
691
|
+ group = user_group, data_handler = 'password', internal = False)
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+#em.save('xmlfile', filename = 'examples/em_test.xml')
|
|
695
|
+pickle_file = 'examples/em_simple.pickle'
|
|
696
|
+em.save('picklefile', filename = pickle_file)
|
|
697
|
+print("Output written in %s" % pickle_file)
|