server/test/data-migractions/schema.py
author David Douard <david.douard@logilab.fr>
Wed, 22 Jul 2015 19:50:50 +0200
changeset 10551 1182f5f16a3d
parent 10487 49a5c38de1de
child 10815 bc679f7e96d8
permissions -rw-r--r--
[datafeed] fix typo in DataFeedXMLParser.is_deleted (closes #5729755)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10487
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     1
# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     3
#
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     4
# This file is part of CubicWeb.
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     5
#
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     9
# any later version.
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    10
#
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    13
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    14
# details.
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    15
#
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    18
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    19
from yams.buildobjs import (EntityType, RelationType, RelationDefinition, ComputedRelation,
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    20
                            SubjectRelation, RichString, String, Int, Float,
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    21
                            Boolean, Datetime, TZDatetime, Bytes)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    22
from yams.constraints import SizeConstraint
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    23
from cubicweb.schema import (WorkflowableEntityType,
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    24
                             RQLConstraint, RQLUniqueConstraint,
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    25
                             RQLVocabularyConstraint,
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    26
                             ERQLExpression, RRQLExpression)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    27
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    28
class Affaire(WorkflowableEntityType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    29
    __permissions__ = {
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    30
        'read':   ('managers',
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    31
                   ERQLExpression('X owned_by U'), ERQLExpression('X concerne S?, S owned_by U')),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    32
        'add':    ('managers', ERQLExpression('X concerne S, S owned_by U')),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    33
        'update': ('managers', 'owners', ERQLExpression('X in_state S, S name in ("pitetre", "en cours")')),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    34
        'delete': ('managers', 'owners', ERQLExpression('X concerne S, S owned_by U')),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    35
        }
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    36
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    37
    ref = String(fulltextindexed=True, indexed=True,
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    38
                 constraints=[SizeConstraint(16)])
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    39
    sujet = String(fulltextindexed=True,
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    40
                   constraints=[SizeConstraint(256)])
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    41
    descr = RichString(fulltextindexed=True,
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    42
                       description=_('more detailed description'))
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    43
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    44
    duration = Int()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    45
    invoiced = Float()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    46
    opt_attr = Bytes()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    47
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    48
    depends_on = SubjectRelation('Affaire')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    49
    require_permission = SubjectRelation('CWPermission')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    50
    concerne = SubjectRelation(('Societe', 'Note'))
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    51
    todo_by = SubjectRelation('Personne', cardinality='?*')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    52
    documented_by = SubjectRelation('Card')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    53
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    54
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    55
class Societe(EntityType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    56
    __unique_together__ = [('nom', 'type', 'cp')]
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    57
    __permissions__ = {
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    58
        'read': ('managers', 'users', 'guests'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    59
        'update': ('managers', 'owners', ERQLExpression('U login L, X nom L')),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    60
        'delete': ('managers', 'owners', ERQLExpression('U login L, X nom L')),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    61
        'add': ('managers', 'users',)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    62
        }
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    63
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    64
    nom  = String(maxsize=64, fulltextindexed=True)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    65
    web  = String(maxsize=128)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    66
    type  = String(maxsize=128) # attribute in common with Note
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    67
    tel  = Int()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    68
    fax  = Int()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    69
    rncs = String(maxsize=128)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    70
    ad1  = String(maxsize=128)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    71
    ad2  = String(maxsize=128)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    72
    ad3  = String(maxsize=128)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    73
    cp   = String(maxsize=12)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    74
    ville= String(maxsize=32)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    75
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    76
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    77
class Division(Societe):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    78
    __specializes_schema__ = True
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    79
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    80
class SubDivision(Division):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    81
    __specializes_schema__ = True
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    82
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    83
class travaille_subdivision(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    84
    subject = 'Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    85
    object = 'SubDivision'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    86
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    87
from cubicweb.schemas.base import CWUser
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    88
CWUser.get_relations('login').next().fulltextindexed = True
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    89
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    90
class Note(WorkflowableEntityType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    91
    date = String(maxsize=10)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    92
    type = String(vocabulary=[u'todo', u'a', u'b', u'T', u'lalala'])
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    93
    para = String(maxsize=512,
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    94
                  __permissions__ = {
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    95
                      'add': ('managers', ERQLExpression('X in_state S, S name "todo"')),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    96
                      'read':   ('managers', 'users', 'guests'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    97
                      'update': ('managers', ERQLExpression('X in_state S, S name "todo"')),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    98
                      })
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    99
    something = String(maxsize=1,
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   100
                      __permissions__ = {
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   101
                          'read': ('managers', 'users', 'guests'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   102
                          'add': (ERQLExpression('NOT X para NULL'),),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   103
                          'update': ('managers', 'owners')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   104
                      })
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   105
    migrated_from = SubjectRelation('Note')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   106
    attachment = SubjectRelation('File')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   107
    inline1 = SubjectRelation('Affaire', inlined=True, cardinality='?*',
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   108
                              constraints=[RQLUniqueConstraint('S type T, S inline1 A1, A1 todo_by C, '
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   109
                                                              'Y type T, Y inline1 A2, A2 todo_by C',
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   110
                                                               'S,Y')])
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   111
    todo_by = SubjectRelation('CWUser')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   112
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   113
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   114
class Frozable(EntityType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   115
    __permissions__ = {
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   116
        'read':   ('managers', 'users'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   117
        'add':    ('managers', 'users'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   118
        'update': ('managers', ERQLExpression('X frozen False'),),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   119
        'delete': ('managers', ERQLExpression('X frozen False'),)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   120
    }
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   121
    name = String()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   122
    frozen = Boolean(default=False,
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   123
                     __permissions__ = {
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   124
                         'read':   ('managers', 'users'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   125
                         'add':    ('managers', 'users'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   126
                         'update': ('managers', 'owners')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   127
                         })
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   128
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   129
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   130
class Personne(EntityType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   131
    __unique_together__ = [('nom', 'prenom', 'inline2')]
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   132
    nom    = String(fulltextindexed=True, required=True, maxsize=64)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   133
    prenom = String(fulltextindexed=True, maxsize=64)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   134
    sexe   = String(maxsize=1, default='M', fulltextindexed=True)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   135
    promo  = String(vocabulary=('bon','pasbon'))
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   136
    titre  = String(fulltextindexed=True, maxsize=128)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   137
    adel   = String(maxsize=128)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   138
    ass    = String(maxsize=128)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   139
    web    = String(maxsize=128)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   140
    tel    = Int()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   141
    fax    = Int()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   142
    datenaiss = Datetime()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   143
    tzdatenaiss = TZDatetime()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   144
    test   = Boolean(__permissions__={
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   145
        'read': ('managers', 'users', 'guests'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   146
        'add': ('managers',),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   147
        'update': ('managers',),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   148
        })
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   149
    description = String()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   150
    firstname = String(fulltextindexed=True, maxsize=64)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   151
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   152
    concerne = SubjectRelation('Affaire')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   153
    connait = SubjectRelation('Personne')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   154
    inline2 = SubjectRelation('Affaire', inlined=True, cardinality='?*')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   155
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   156
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   157
class Old(EntityType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   158
    name = String(__permissions__ = {
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   159
        'read'   : ('managers', 'users', 'guests'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   160
        'add'    : ('managers', 'users', 'guests'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   161
        'update' : ()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   162
    })
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   163
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   164
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   165
class connait(RelationType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   166
    symmetric = True
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   167
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   168
class concerne(RelationType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   169
    __permissions__ = {
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   170
        'read':   ('managers', 'users', 'guests'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   171
        'add':    ('managers', RRQLExpression('U has_update_permission S')),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   172
        'delete': ('managers', RRQLExpression('O owned_by U')),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   173
        }
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   174
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   175
class travaille(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   176
    __permissions__ = {
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   177
        'read':   ('managers', 'users', 'guests'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   178
        'add':    ('managers', RRQLExpression('U has_update_permission S')),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   179
        'delete': ('managers', RRQLExpression('O owned_by U')),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   180
        }
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   181
    subject = 'Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   182
    object = 'Societe'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   183
    constraints = [RQLVocabularyConstraint('S owned_by U'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   184
                   RQLVocabularyConstraint('S created_by U')]
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   185
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   186
class comments(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   187
    subject = 'Comment'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   188
    object = 'Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   189
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   190
class fiche(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   191
    inlined = True
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   192
    subject = 'Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   193
    object = 'Card'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   194
    cardinality = '??'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   195
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   196
class multisource_inlined_rel(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   197
    inlined = True
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   198
    cardinality = '?*'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   199
    subject = ('Card', 'Note')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   200
    object = ('Affaire', 'Note')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   201
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   202
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   203
class see_also_1(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   204
    name = 'see_also'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   205
    subject = object = 'Folder'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   206
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   207
class see_also_2(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   208
    name = 'see_also'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   209
    subject = ('Bookmark', 'Note')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   210
    object = ('Bookmark', 'Note')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   211
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   212
class evaluee(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   213
    subject = ('Personne', 'CWUser', 'Societe')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   214
    object = ('Note')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   215
    constraints = [
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   216
        RQLVocabularyConstraint('S created_by U'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   217
        RQLVocabularyConstraint('S owned_by U'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   218
    ]
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   219
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   220
class ecrit_par(RelationType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   221
    inlined = True
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   222
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   223
class ecrit_par_1(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   224
    name = 'ecrit_par'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   225
    subject = 'Note'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   226
    object ='Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   227
    cardinality = '?*'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   228
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   229
class ecrit_par_2(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   230
    name = 'ecrit_par'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   231
    subject = 'Note'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   232
    object ='CWUser'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   233
    cardinality='?*'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   234
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   235
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   236
class copain(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   237
    subject = object = 'CWUser'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   238
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   239
class tags(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   240
    subject = 'Tag'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   241
    object = ('CWUser', 'CWGroup', 'State', 'Note', 'Card', 'Affaire')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   242
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   243
class Folder(EntityType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   244
    """folders are used to classify entities. They may be defined as a tree.
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   245
    """
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   246
    name = String(required=True, indexed=True, internationalizable=True,
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   247
                  maxsize=64)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   248
    description = RichString(fulltextindexed=True)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   249
    filed_under = SubjectRelation('Folder', description=_('parent folder'))
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   250
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   251
class filed_under(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   252
    subject = ('Note', 'Affaire')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   253
    object = 'Folder'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   254
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   255
class require_permission(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   256
    subject = ('Card', 'Note', 'Personne')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   257
    object = 'CWPermission'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   258
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   259
class require_state(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   260
    subject = 'CWPermission'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   261
    object = 'State'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   262
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   263
class personne_composite(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   264
    subject='Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   265
    object='Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   266
    composite='subject'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   267
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   268
class personne_inlined(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   269
    subject='Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   270
    object='Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   271
    cardinality='?*'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   272
    inlined=True
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   273
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   274
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   275
class login_user(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   276
    subject = 'Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   277
    object = 'CWUser'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   278
    cardinality = '??'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   279
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   280
class ambiguous_inlined(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   281
    subject = ('Affaire', 'Note')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   282
    object = 'CWUser'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   283
    inlined = True
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   284
    cardinality = '?*'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   285
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   286
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   287
class user_login(ComputedRelation):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   288
    rule = 'O login_user S'