123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- #-*- coding: utf-8 -*-
-
- from lodel.editorial_model.components import *
- from lodel.editorial_model.exceptions import *
- from lodel.editorial_model.model import EditorialModel
-
- em = EditorialModel('testem', 'Test editorial model')
-
- base_group = em.new_group( 'base_group',
- display_name = 'Base group',
- help_text = 'Base group that implements base EM features (like classtype)'
- )
-
- ####################
- # Lodel Object #
- ####################
- em_object = em.new_class( 'object',
- display_name = 'Object',
- help_text = 'Main class for all Em objects',
- group = base_group,
- abstract = True,
- )
- em_object.new_field( 'lodel_id',
- display_name = 'Lodel identifier',
- help_text = 'Uniq ID that identify every lodel object',
- group = base_group,
- data_handler = 'integer',
- internal = True,
- )
- em_object.new_field( 'help_text',
- display_name = 'Help',
- help_text = 'A short text that describe the object',
- group = base_group,
- internal = True,
- data_handler = 'text',
- )
-
- em_object.new_field( 'date_create',
- display_name = 'Creation date',
- group = base_group,
- data_handler = 'datetime',
- now_on_create = True,
- )
- em_object.new_field( 'date_update',
- display_name = 'Last update',
- group = base_group,
- data_handler = 'datetime',
- now_on_update = True,
- )
- em_object.new_field( 'classname',
- display_name = 'Class name',
- group = base_group,
- data_handler = 'varchar',
- immutable = True
- )
-
- ########################
- # Lodel old classtypes #
- ########################
- entitie = em.new_class( 'entitie',
- display_name = 'entitie',
- help_text = 'Replace old entity classtype',
- abstract = True,
- group = base_group,
- parents = em_object,
- )
-
- person = em.new_class( 'person',
- display_name = 'Person',
- help_text = 'Replace old person classtype',
- abstract = True,
- group = base_group,
- parents = em_object,
- )
-
- person.new_field( 'firstname',
- display_name = {
- 'eng': 'Firstname',
- 'fre': 'Prénom',
- },
- data_handler = 'varchar',
- )
- person.new_field( 'lastname',
- display_name = {
- 'eng': 'Lastname',
- 'fre': 'Nom de famille',
- },
- data_handler = 'varchar',
- )
- person.new_field( 'fullname',
- display_name = {
- 'eng': 'Fullname',
- 'fre': 'Nom complet',
- },
- group = base_group,
- data_handler = 'varchar', # <-- should be concat type
- internal = True,
- immutable = True,
- )
- person.new_field( 'alias',
- display_name = 'alias',
- help_text = {
- 'eng': 'Link to other person class instance that represent the same person',
- 'fre': 'Lien vers un ensemble d\'instances de la classe personne représentant le même individu',
- },
- data_handler = 'set',
- allowed_classes = [person],
- )
-
-
- entry = em.new_class( 'entry',
- display_name = 'Entry',
- help_text = 'Replace olf entry classtype',
- abstract = True,
- group = base_group,
- parents = em_object,
- )
-
- #####################
- # Editorial classes #
- #####################
-
- editorial_group = em.new_group( 'editorial_abstract',
- display_name = 'Editorial base',
- help_text = {
- 'eng': 'Contains abstract class to handler editorial contents',
- 'fre': 'Contient les classes abstraites permetant la gestion de contenu éditorial'
- },
- depends = (base_group,)
- )
-
- # Classe texte
- text = em.new_class( 'text',
- display_name = 'Text',
- help_text = 'Abstract class that represent texts',
- group = editorial_group,
- abstract = True,
- )
-
- text.new_field( 'title',
- display_name = {'eng': 'Title', 'fre': 'Titre'},
- group = editorial_group,
- data_handler = 'varchar',
- )
- text.new_field( 'subtitle',
- display_name = {
- 'eng': 'Subtitle',
- 'fre': 'Sous-titre',
- },
- group = editorial_group,
- data_handler = 'varchar',
- )
-
- # Classe collection
- collection = em.new_class( 'collection',
- display_name = 'Collection',
- group = editorial_group,
- abstract = True,
- )
- collection.new_field( 'title',
- display_name = 'Title',
- group = editorial_group,
- abstract = True,
- data_handler = 'varchar'
- )
-
- #####################
- # Persons & authors #
- #####################
-
- editorial_person_group = em.new_group( 'editorial_person',
- display_name = 'Editorial person',
- help_text = {
- 'eng': 'Introduce the concept of editorial person (authors, translator etc)',
- 'fre': 'Contient les classes servant à la gestion des personnes editorials (auteurs, traducteur...)',
- },
- depends = (editorial_group,)
- )
- text_person = em.new_class( 'text_person',
- display_name = {
- 'eng': 'TextPerson',
- 'fre': 'TextePersonne',
- },
- help_text = {
- 'eng': 'Represent a link between someone and a text',
- 'fre': 'Représente un lien entre une personne et un texte',
- },
- group = editorial_person_group,
- abstract = True,
- )
- bref_textperson_text = text_person.new_field( 'text',
- display_name = {
- 'eng': 'Linked text',
- 'fre': 'Texte lié',
- },
- data_handler = 'link',
- allowed_classes = [text],
- group = editorial_person_group
- )
- bref_textperson_person = text_person.new_field( 'person',
- display_name = {
- 'eng': 'Linked person',
- 'fre': 'Personne liée',
- },
- data_handler = 'link',
- allowed_classes = [person],
- group = editorial_person_group,
- )
- text_person.new_field( 'role',
- display_name = {
- 'eng': 'Person role',
- 'fre': 'Role de la personne',
- },
- data_handler = 'varchar',
- group = editorial_person_group
- )
-
- person.new_field( 'linked_texts',
- display_name = {
- 'eng': 'Linked texts',
- 'fre': 'Textes liés',
- },
- data_handler = 'relation',
- data_handler_kwargs = {
- 'data_handler': 'list',
- 'allowed_class': text_person,
- 'backreference': bref_textperson_text,
- },
- group = editorial_person_group,
- )
-
- text.new_field( 'linked_persons',
- display_name = {
- 'eng': 'Linked persons',
- 'fre': 'Personnes liées',
- },
- data_handler = 'relation',
- data_handler_kwargs = {
- 'data_handler': 'list',
- 'allowed_class': text_person,
- 'backreference': bref_textperson_person,
-
- },
- group = editorial_person_group,
- )
-
- em.save('picklefile', filename = '/tmp/em_test.pickle')
|