server/test/data/migratedapp/schema.py
author Julien Cristau <julien.cristau@logilab.fr>
Thu, 08 Jan 2015 12:22:43 +0100
changeset 10146 78f541f50369
parent 9984 793377697c81
child 10303 593e63a68429
child 10584 743ed2b13a6f
permissions -rw-r--r--
[doc] remove nonexistent css from theme
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9394
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
     1
# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
     3
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
     4
# This file is part of CubicWeb.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
     5
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
     9
# any later version.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
    10
#
5424
8ecbcbff9777 replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5421
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
    13
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
    14
# details.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
    15
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
6790
f4f67ea5436a [schema migration] add a test to ensure default value are considered
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6292
diff changeset
    18
"""cw.server.migraction test"""
9299
c5eed908117d [schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents: 8105
diff changeset
    19
import datetime as dt
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    20
from yams.buildobjs import (EntityType, RelationType, RelationDefinition,
7711
458cb2edf63a [repo test] Fix test broken by BFSSTestable
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 6790
diff changeset
    21
                            SubjectRelation, Bytes,
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    22
                            RichString, String, Int, Boolean, Datetime, Date)
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    23
from yams.constraints import SizeConstraint, UniqueConstraint
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    24
from cubicweb.schema import (WorkflowableEntityType, RQLConstraint,
9565
fa00fc251d57 [migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8105
diff changeset
    25
                             RQLVocabularyConstraint,
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    26
                             ERQLExpression, RRQLExpression)
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    27
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    28
class Affaire(EntityType):
3877
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3546
diff changeset
    29
    __permissions__ = {
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    30
        'read':   ('managers', 'users', 'guests'),
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    31
        'add':    ('managers', ERQLExpression('X concerne S, S owned_by U')),
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    32
        'update': ('managers', 'owners', ERQLExpression('X concerne S, S owned_by U')),
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    33
        'delete': ('managers', 'owners', ERQLExpression('X concerne S, S owned_by U')),
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    34
        }
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    35
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    36
    ref = String(fulltextindexed=True, indexed=True,
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    37
                 constraints=[SizeConstraint(16)])
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    38
    sujet = String(fulltextindexed=True,
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    39
                 constraints=[SizeConstraint(256)])
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    40
    concerne = SubjectRelation('Societe')
7711
458cb2edf63a [repo test] Fix test broken by BFSSTestable
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 6790
diff changeset
    41
    opt_attr = Bytes()
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    42
9394
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
    43
class Societe(WorkflowableEntityType):
3877
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3546
diff changeset
    44
    __permissions__ = {
9394
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
    45
        'read': ('managers', 'users', 'guests'),
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
    46
        'update': ('managers', 'owners'),
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
    47
        'delete': ('managers', 'owners'),
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
    48
        'add': ('managers', 'users',)
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    49
        }
9394
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
    50
    nom  = String(maxsize=64, fulltextindexed=True)
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
    51
    web  = String(maxsize=128)
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
    52
    tel  = Int()
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
    53
    fax  = Int()
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
    54
    rncs = String(maxsize=128)
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
    55
    ad1  = String(maxsize=128)
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
    56
    ad2  = String(maxsize=128)
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
    57
    ad3  = String(maxsize=128)
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
    58
    cp   = String(maxsize=12)
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
    59
    ville= String(maxsize=32)
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    60
9394
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
    61
# Division and SubDivision are gone
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
    62
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
    63
# New
2963
12ad88615a12 test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2745
diff changeset
    64
class Para(EntityType):
12ad88615a12 test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2745
diff changeset
    65
    para = String(maxsize=512)
12ad88615a12 test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2745
diff changeset
    66
    newattr = String()
12ad88615a12 test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2745
diff changeset
    67
    newinlined = SubjectRelation('Affaire', cardinality='?*', inlined=True)
12ad88615a12 test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2745
diff changeset
    68
    newnotinlined = SubjectRelation('Affaire', cardinality='?*')
12ad88615a12 test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2745
diff changeset
    69
12ad88615a12 test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2745
diff changeset
    70
class Note(Para):
12ad88615a12 test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2745
diff changeset
    71
    __specializes_schema__ = True
12ad88615a12 test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2745
diff changeset
    72
3877
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3546
diff changeset
    73
    __permissions__ = {'read':   ('managers', 'users', 'guests',),
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    74
                   'update': ('managers', 'owners',),
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    75
                   'delete': ('managers', ),
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    76
                   'add':    ('managers',
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    77
                              ERQLExpression('X ecrit_part PE, U in_group G, '
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    78
                                             'PE require_permission P, P name "add_note", '
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    79
                                             'P require_group G'),)}
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    80
9299
c5eed908117d [schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents: 8105
diff changeset
    81
    whatever = Int(default=0)  # keep it before `date` for unittest_migraction.test_add_attribute_int
c5eed908117d [schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents: 8105
diff changeset
    82
    yesno = Boolean(default=False)
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    83
    date = Datetime()
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    84
    type = String(maxsize=1)
6292
054fa36060d5 [migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 6208
diff changeset
    85
    unique_id = String(maxsize=1, required=True, unique=True)
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    86
    mydate = Date(default='TODAY')
9299
c5eed908117d [schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents: 8105
diff changeset
    87
    oldstyledefaultdate = Date(default='2013/01/01')
c5eed908117d [schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents: 8105
diff changeset
    88
    newstyledefaultdate = Date(default=dt.date(2013, 1, 1))
6790
f4f67ea5436a [schema migration] add a test to ensure default value are considered
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6292
diff changeset
    89
    shortpara = String(maxsize=64, default='hop')
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    90
    ecrit_par = SubjectRelation('Personne', constraints=[RQLConstraint('S concerne A, O concerne A')])
5575
8a531340c3ef no more Image type w/ cw 3.9
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5426
diff changeset
    91
    attachment = SubjectRelation('File')
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    92
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    93
9981
7099bbd685aa [hooks/security] allow edition of attributes with permissive permissions
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9600
diff changeset
    94
class Frozable(EntityType):
7099bbd685aa [hooks/security] allow edition of attributes with permissive permissions
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9600
diff changeset
    95
    __permissions__ = {
7099bbd685aa [hooks/security] allow edition of attributes with permissive permissions
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9600
diff changeset
    96
        'read':   ('managers', 'users'),
7099bbd685aa [hooks/security] allow edition of attributes with permissive permissions
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9600
diff changeset
    97
        'add':    ('managers', 'users'),
7099bbd685aa [hooks/security] allow edition of attributes with permissive permissions
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9600
diff changeset
    98
        'update': ('managers', ERQLExpression('X frozen False'),),
7099bbd685aa [hooks/security] allow edition of attributes with permissive permissions
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9600
diff changeset
    99
        'delete': ('managers', ERQLExpression('X frozen False'),)
7099bbd685aa [hooks/security] allow edition of attributes with permissive permissions
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9600
diff changeset
   100
    }
7099bbd685aa [hooks/security] allow edition of attributes with permissive permissions
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9600
diff changeset
   101
    name = String()
7099bbd685aa [hooks/security] allow edition of attributes with permissive permissions
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9600
diff changeset
   102
    frozen = Boolean(default=False,
7099bbd685aa [hooks/security] allow edition of attributes with permissive permissions
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9600
diff changeset
   103
                     __permissions__ = {
7099bbd685aa [hooks/security] allow edition of attributes with permissive permissions
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9600
diff changeset
   104
                         'read':   ('managers', 'users'),
7099bbd685aa [hooks/security] allow edition of attributes with permissive permissions
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9600
diff changeset
   105
                         'add':    ('managers', 'users'),
7099bbd685aa [hooks/security] allow edition of attributes with permissive permissions
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9600
diff changeset
   106
                         'update': ('managers', 'owners')
7099bbd685aa [hooks/security] allow edition of attributes with permissive permissions
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9600
diff changeset
   107
                         })
7099bbd685aa [hooks/security] allow edition of attributes with permissive permissions
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9600
diff changeset
   108
7099bbd685aa [hooks/security] allow edition of attributes with permissive permissions
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9600
diff changeset
   109
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   110
class Personne(EntityType):
6208
07b176640a8c unique_together integration in CW (alf+syt)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6163
diff changeset
   111
    __unique_together__ = [('nom', 'prenom', 'datenaiss')]
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   112
    nom    = String(fulltextindexed=True, required=True, maxsize=64)
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   113
    prenom = String(fulltextindexed=True, maxsize=64)
3546
f0aecddf367e fix bug when renaming a full text indexed attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3543
diff changeset
   114
    civility   = String(maxsize=1, default='M', fulltextindexed=True)
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   115
    promo  = String(vocabulary=('bon','pasbon'))
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   116
    titre  = String(fulltextindexed=True, maxsize=128)
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   117
    adel   = String(maxsize=128)
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   118
    ass    = String(maxsize=128)
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   119
    web    = String(maxsize=128)
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   120
    tel    = Int()
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   121
    fax    = Int()
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   122
    datenaiss = Datetime()
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   123
    test   = Boolean()
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   124
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   125
    travaille = SubjectRelation('Societe')
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   126
    concerne = SubjectRelation('Affaire')
2745
0dafa29ace1f [schema migration] test reproducing pb when deleting a relation definition with mandatory card and without removing the associated rtype + fix
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2637
diff changeset
   127
    concerne2 = SubjectRelation(('Affaire', 'Note'), cardinality='1*')
4467
0e73d299730a fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
   128
    connait = SubjectRelation('Personne', symmetric=True)
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   129
9394
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   130
class concerne(RelationType):
3877
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3546
diff changeset
   131
    __permissions__ = {
9394
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   132
        'read':   ('managers', 'users', 'guests'),
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   133
        'add':    ('managers', RRQLExpression('U has_update_permission S')),
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   134
        'delete': ('managers', RRQLExpression('O owned_by U')),
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   135
        }
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   136
9394
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   137
# `Old` entity type is gonce
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   138
# `comments` is gone
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   139
# `fiche` is gone
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   140
# `multisource_*` rdefs are gone
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   141
# `see_also_*` rdefs are gone
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   142
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   143
class evaluee(RelationDefinition):
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   144
    subject = ('Personne', 'CWUser', 'Societe')
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   145
    object = ('Note')
9636
e35ae8617c03 Fix constraint sync during migration
Julien Cristau <julien.cristau@logilab.fr>
parents: 9600
diff changeset
   146
    constraints = [RQLVocabularyConstraint('S owned_by U')]
9394
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   147
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   148
class ecrit_par(RelationType):
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   149
    __permissions__ = {'read':   ('managers', 'users', 'guests',),
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   150
                   'delete': ('managers', ),
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   151
                   'add':    ('managers',
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   152
                              RRQLExpression('O require_permission P, P name "add_note", '
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   153
                                             'U in_group G, P require_group G'),)
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   154
                   }
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   155
    inlined = True
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   156
    cardinality = '?*'
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   157
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   158
# `copain` rdef is gone
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   159
# `tags` rdef is gone
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   160
# `filed_under` rdef is gone
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   161
# `require_permission` rdef is gone
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   162
# `require_state` rdef is gone
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   163
# `personne_composite` rdef is gone
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   164
# `personne_inlined` rdef is gone
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   165
# `login_user` rdef is gone
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   166
# `ambiguous_inlined` rdef is gone
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   167
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   168
# New
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   169
class Text(Para):
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   170
    __specializes_schema__ = True
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   171
    summary = String(maxsize=512)
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   172
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   173
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   174
# New
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   175
class Folder2(EntityType):
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   176
    """folders are used to classify entities. They may be defined as a tree.
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   177
    When you include the Folder entity, all application specific entities
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   178
    may then be classified using the "filed_under" relation.
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   179
    """
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   180
    name = String(required=True, indexed=True, internationalizable=True,
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   181
                  constraints=[UniqueConstraint(), SizeConstraint(64)])
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   182
    description = RichString(fulltextindexed=True)
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   183
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   184
# New
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   185
class filed_under2(RelationDefinition):
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   186
    subject ='*'
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   187
    object = 'Folder2'
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   188
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   189
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   190
# New
8105
7980b36fb1aa [schema sync] Update repo._type_source_cache when renaming an entity (closes #2094470)
Julien Cristau <julien.cristau@logilab.fr>
parents: 7711
diff changeset
   191
class New(EntityType):
7980b36fb1aa [schema sync] Update repo._type_source_cache when renaming an entity (closes #2094470)
Julien Cristau <julien.cristau@logilab.fr>
parents: 7711
diff changeset
   192
    new_name = String()
7980b36fb1aa [schema sync] Update repo._type_source_cache when renaming an entity (closes #2094470)
Julien Cristau <julien.cristau@logilab.fr>
parents: 7711
diff changeset
   193
9394
4b89ca0b11ad [server/test] reorganize data/migratedapp/schema.py to allow comparison with data/schema.py
Julien Cristau <julien.cristau@logilab.fr>
parents: 9299
diff changeset
   194
# New
6163
407f54345687 [migration] fix add_relation_type() for symmetric relations
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 5575
diff changeset
   195
class same_as(RelationDefinition):
407f54345687 [migration] fix add_relation_type() for symmetric relations
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 5575
diff changeset
   196
    subject = ('Societe',)
407f54345687 [migration] fix add_relation_type() for symmetric relations
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 5575
diff changeset
   197
    object = 'ExternalUri'