server/test/data-migractions/schema.py
author Julien Cristau <julien.cristau@logilab.fr>
Mon, 23 Nov 2015 17:58:10 +0100
changeset 10897 7c386161ebd6
parent 10817 7b154e0fa194
child 10918 6b1445cfccdf
permissions -rw-r--r--
[web] remove PropertySheet._cache Instead of remembering that a css file has been processed, we re-process it at every request. This prevents our cache getting out of date with the file system. Closes #6893185 While we're at it, write the file atomically so that we don't risk serving partial data.
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)
10817
7b154e0fa194 Use cubicweb._
Julien Cristau <julien.cristau@logilab.fr>
parents: 10815
diff changeset
    27
from cubicweb import _
7b154e0fa194 Use cubicweb._
Julien Cristau <julien.cristau@logilab.fr>
parents: 10815
diff changeset
    28
10487
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    29
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    30
class Affaire(WorkflowableEntityType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    31
    __permissions__ = {
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    32
        'read':   ('managers',
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    33
                   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
    34
        '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
    35
        '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
    36
        '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
    37
        }
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    38
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    39
    ref = String(fulltextindexed=True, indexed=True,
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    40
                 constraints=[SizeConstraint(16)])
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    41
    sujet = String(fulltextindexed=True,
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    42
                   constraints=[SizeConstraint(256)])
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    43
    descr = RichString(fulltextindexed=True,
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    44
                       description=_('more detailed description'))
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    45
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    46
    duration = Int()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    47
    invoiced = Float()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    48
    opt_attr = Bytes()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    49
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    50
    depends_on = SubjectRelation('Affaire')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    51
    require_permission = SubjectRelation('CWPermission')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    52
    concerne = SubjectRelation(('Societe', 'Note'))
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    53
    todo_by = SubjectRelation('Personne', cardinality='?*')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    54
    documented_by = SubjectRelation('Card')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    55
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    56
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    57
class Societe(EntityType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    58
    __unique_together__ = [('nom', 'type', 'cp')]
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    59
    __permissions__ = {
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    60
        'read': ('managers', 'users', 'guests'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    61
        '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
    62
        '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
    63
        'add': ('managers', 'users',)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    64
        }
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    65
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    66
    nom  = String(maxsize=64, fulltextindexed=True)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    67
    web  = String(maxsize=128)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    68
    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
    69
    tel  = Int()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    70
    fax  = Int()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    71
    rncs = String(maxsize=128)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    72
    ad1  = String(maxsize=128)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    73
    ad2  = String(maxsize=128)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    74
    ad3  = String(maxsize=128)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    75
    cp   = String(maxsize=12)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    76
    ville= String(maxsize=32)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    77
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    78
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    79
class Division(Societe):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    80
    __specializes_schema__ = True
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    81
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    82
class SubDivision(Division):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    83
    __specializes_schema__ = True
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    84
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    85
class travaille_subdivision(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    86
    subject = 'Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    87
    object = 'SubDivision'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    88
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    89
from cubicweb.schemas.base import CWUser
10815
bc679f7e96d8 [server/test] use next() builtin instead of next() method
Julien Cristau <julien.cristau@logilab.fr>
parents: 10487
diff changeset
    90
next(CWUser.get_relations('login')).fulltextindexed = True
10487
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    91
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    92
class Note(WorkflowableEntityType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    93
    date = String(maxsize=10)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    94
    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
    95
    para = String(maxsize=512,
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    96
                  __permissions__ = {
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    97
                      '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
    98
                      'read':   ('managers', 'users', 'guests'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    99
                      '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
   100
                      })
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   101
    something = String(maxsize=1,
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   102
                      __permissions__ = {
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   103
                          'read': ('managers', 'users', 'guests'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   104
                          'add': (ERQLExpression('NOT X para NULL'),),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   105
                          'update': ('managers', 'owners')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   106
                      })
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   107
    migrated_from = SubjectRelation('Note')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   108
    attachment = SubjectRelation('File')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   109
    inline1 = SubjectRelation('Affaire', inlined=True, cardinality='?*',
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   110
                              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
   111
                                                              '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
   112
                                                               'S,Y')])
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   113
    todo_by = SubjectRelation('CWUser')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   114
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   115
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   116
class Frozable(EntityType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   117
    __permissions__ = {
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   118
        'read':   ('managers', 'users'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   119
        'add':    ('managers', 'users'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   120
        'update': ('managers', ERQLExpression('X frozen False'),),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   121
        'delete': ('managers', ERQLExpression('X frozen False'),)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   122
    }
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   123
    name = String()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   124
    frozen = Boolean(default=False,
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   125
                     __permissions__ = {
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   126
                         'read':   ('managers', 'users'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   127
                         'add':    ('managers', 'users'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   128
                         'update': ('managers', 'owners')
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
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   131
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   132
class Personne(EntityType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   133
    __unique_together__ = [('nom', 'prenom', 'inline2')]
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   134
    nom    = String(fulltextindexed=True, required=True, maxsize=64)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   135
    prenom = String(fulltextindexed=True, maxsize=64)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   136
    sexe   = String(maxsize=1, default='M', fulltextindexed=True)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   137
    promo  = String(vocabulary=('bon','pasbon'))
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   138
    titre  = String(fulltextindexed=True, maxsize=128)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   139
    adel   = String(maxsize=128)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   140
    ass    = String(maxsize=128)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   141
    web    = String(maxsize=128)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   142
    tel    = Int()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   143
    fax    = Int()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   144
    datenaiss = Datetime()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   145
    tzdatenaiss = TZDatetime()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   146
    test   = Boolean(__permissions__={
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   147
        'read': ('managers', 'users', 'guests'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   148
        'add': ('managers',),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   149
        'update': ('managers',),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   150
        })
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   151
    description = String()
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   152
    firstname = String(fulltextindexed=True, maxsize=64)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   153
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   154
    concerne = SubjectRelation('Affaire')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   155
    connait = SubjectRelation('Personne')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   156
    inline2 = SubjectRelation('Affaire', inlined=True, cardinality='?*')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   157
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   158
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   159
class Old(EntityType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   160
    name = String(__permissions__ = {
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   161
        'read'   : ('managers', 'users', 'guests'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   162
        'add'    : ('managers', 'users', 'guests'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   163
        'update' : ()
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
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   166
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   167
class connait(RelationType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   168
    symmetric = True
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   169
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   170
class concerne(RelationType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   171
    __permissions__ = {
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   172
        'read':   ('managers', 'users', 'guests'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   173
        'add':    ('managers', RRQLExpression('U has_update_permission S')),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   174
        'delete': ('managers', RRQLExpression('O owned_by U')),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   175
        }
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   176
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   177
class travaille(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   178
    __permissions__ = {
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   179
        'read':   ('managers', 'users', 'guests'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   180
        'add':    ('managers', RRQLExpression('U has_update_permission S')),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   181
        'delete': ('managers', RRQLExpression('O owned_by U')),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   182
        }
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   183
    subject = 'Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   184
    object = 'Societe'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   185
    constraints = [RQLVocabularyConstraint('S owned_by U'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   186
                   RQLVocabularyConstraint('S created_by U')]
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   187
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   188
class comments(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   189
    subject = 'Comment'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   190
    object = 'Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   191
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   192
class fiche(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   193
    inlined = True
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   194
    subject = 'Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   195
    object = 'Card'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   196
    cardinality = '??'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   197
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   198
class multisource_inlined_rel(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   199
    inlined = True
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   200
    cardinality = '?*'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   201
    subject = ('Card', 'Note')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   202
    object = ('Affaire', 'Note')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   203
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   204
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   205
class see_also_1(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   206
    name = 'see_also'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   207
    subject = object = 'Folder'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   208
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   209
class see_also_2(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   210
    name = 'see_also'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   211
    subject = ('Bookmark', 'Note')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   212
    object = ('Bookmark', 'Note')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   213
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   214
class evaluee(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   215
    subject = ('Personne', 'CWUser', 'Societe')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   216
    object = ('Note')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   217
    constraints = [
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   218
        RQLVocabularyConstraint('S created_by U'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   219
        RQLVocabularyConstraint('S owned_by U'),
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   220
    ]
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   221
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   222
class ecrit_par(RelationType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   223
    inlined = True
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   224
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   225
class ecrit_par_1(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   226
    name = 'ecrit_par'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   227
    subject = 'Note'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   228
    object ='Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   229
    cardinality = '?*'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   230
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   231
class ecrit_par_2(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   232
    name = 'ecrit_par'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   233
    subject = 'Note'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   234
    object ='CWUser'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   235
    cardinality='?*'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   236
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   237
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   238
class copain(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   239
    subject = object = 'CWUser'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   240
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   241
class tags(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   242
    subject = 'Tag'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   243
    object = ('CWUser', 'CWGroup', 'State', 'Note', 'Card', 'Affaire')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   244
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   245
class Folder(EntityType):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   246
    """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
   247
    """
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   248
    name = String(required=True, indexed=True, internationalizable=True,
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   249
                  maxsize=64)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   250
    description = RichString(fulltextindexed=True)
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   251
    filed_under = SubjectRelation('Folder', description=_('parent folder'))
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   252
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   253
class filed_under(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   254
    subject = ('Note', 'Affaire')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   255
    object = 'Folder'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   256
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   257
class require_permission(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   258
    subject = ('Card', 'Note', 'Personne')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   259
    object = 'CWPermission'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   260
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   261
class require_state(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   262
    subject = 'CWPermission'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   263
    object = 'State'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   264
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   265
class personne_composite(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   266
    subject='Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   267
    object='Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   268
    composite='subject'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   269
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   270
class personne_inlined(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   271
    subject='Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   272
    object='Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   273
    cardinality='?*'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   274
    inlined=True
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   275
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   276
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   277
class login_user(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   278
    subject = 'Personne'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   279
    object = 'CWUser'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   280
    cardinality = '??'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   281
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   282
class ambiguous_inlined(RelationDefinition):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   283
    subject = ('Affaire', 'Note')
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   284
    object = 'CWUser'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   285
    inlined = True
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   286
    cardinality = '?*'
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   287
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   288
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   289
class user_login(ComputedRelation):
49a5c38de1de [server/test] stop using email cube
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
   290
    rule = 'O login_user S'