server/test/data-migractions/migratedapp/schema.py
author Rémi Cardona <remi.cardona@logilab.fr>
Fri, 09 Oct 2015 17:52:14 +0200
changeset 10646 45671fb330f5
parent 10584 server/test/data/migratedapp/schema.py@743ed2b13a6f
parent 10645 server/test/data/migratedapp/schema.py@57c60a96de70
child 10817 7b154e0fa194
permissions -rw-r--r--
merge with 3.20.10
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,
10645
57c60a96de70 [migration] fix change_attribute_type to update the live schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10487
diff changeset
    22
                            RichString, String, Int, Boolean, Datetime, Date, Float)
2592
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)
10645
57c60a96de70 [migration] fix change_attribute_type to update the live schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10487
diff changeset
    52
    tel  = Float()
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
    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):
10584
743ed2b13a6f [syncschema] only add to the `synchronized` set if all possible updates have been done
Aurelien Campeas <aurelien.campeas@pythonian.fr>
parents: 9984
diff changeset
   111
    __permissions__ = {
743ed2b13a6f [syncschema] only add to the `synchronized` set if all possible updates have been done
Aurelien Campeas <aurelien.campeas@pythonian.fr>
parents: 9984
diff changeset
   112
        'read':   ('managers', 'users'), # 'guests' was removed
743ed2b13a6f [syncschema] only add to the `synchronized` set if all possible updates have been done
Aurelien Campeas <aurelien.campeas@pythonian.fr>
parents: 9984
diff changeset
   113
        'add':    ('managers', 'users'),
743ed2b13a6f [syncschema] only add to the `synchronized` set if all possible updates have been done
Aurelien Campeas <aurelien.campeas@pythonian.fr>
parents: 9984
diff changeset
   114
        'update': ('managers', 'owners'),
743ed2b13a6f [syncschema] only add to the `synchronized` set if all possible updates have been done
Aurelien Campeas <aurelien.campeas@pythonian.fr>
parents: 9984
diff changeset
   115
        'delete': ('managers', 'owners')
743ed2b13a6f [syncschema] only add to the `synchronized` set if all possible updates have been done
Aurelien Campeas <aurelien.campeas@pythonian.fr>
parents: 9984
diff changeset
   116
    }
6208
07b176640a8c unique_together integration in CW (alf+syt)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6163
diff changeset
   117
    __unique_together__ = [('nom', 'prenom', 'datenaiss')]
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   118
    nom    = String(fulltextindexed=True, required=True, maxsize=64)
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   119
    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
   120
    civility   = String(maxsize=1, default='M', fulltextindexed=True)
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   121
    promo  = String(vocabulary=('bon','pasbon'))
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   122
    titre  = String(fulltextindexed=True, maxsize=128)
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   123
    adel   = String(maxsize=128)
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   124
    ass    = String(maxsize=128)
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   125
    web    = String(maxsize=128)
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   126
    tel    = Int()
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   127
    fax    = Int()
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   128
    datenaiss = Datetime()
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   129
    test   = Boolean()
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   130
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   131
    travaille = SubjectRelation('Societe')
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   132
    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
   133
    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
   134
    connait = SubjectRelation('Personne', symmetric=True)
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   135
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
   136
class concerne(RelationType):
3877
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3546
diff changeset
   137
    __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
   138
        '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
   139
        '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
   140
        'delete': ('managers', RRQLExpression('O owned_by U')),
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   141
        }
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   142
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
   143
# `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
   144
# `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
   145
# `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
   146
# `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
   147
# `see_also_*` rdefs are gone
2592
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   148
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   149
class evaluee(RelationDefinition):
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   150
    subject = ('Personne', 'CWUser', 'Societe')
c97c4b56e6a0 rewrite migrscheam
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   151
    object = ('Note')
9636
e35ae8617c03 Fix constraint sync during migration
Julien Cristau <julien.cristau@logilab.fr>
parents: 9600
diff changeset
   152
    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
   153
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
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
   155
    __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
   156
                   '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
   157
                   '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
   158
                              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
   159
                                             '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
   160
                   }
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
    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
   162
    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
   163
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
# `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
   165
# `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
   166
# `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
   167
# `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
   168
# `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
   169
# `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
   170
# `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
   171
# `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
   172
# `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
   173
10303
593e63a68429 [server/test] Drop dependency on folder cube
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9984
diff changeset
   174
class Folder(EntityType):
593e63a68429 [server/test] Drop dependency on folder cube
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9984
diff changeset
   175
    """folders are used to classify entities. They may be defined as a tree.
593e63a68429 [server/test] Drop dependency on folder cube
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9984
diff changeset
   176
    """
593e63a68429 [server/test] Drop dependency on folder cube
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9984
diff changeset
   177
    name = String(required=True, indexed=True, internationalizable=True,
593e63a68429 [server/test] Drop dependency on folder cube
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9984
diff changeset
   178
                  maxsize=64)
593e63a68429 [server/test] Drop dependency on folder cube
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9984
diff changeset
   179
    description = RichString(fulltextindexed=True)
593e63a68429 [server/test] Drop dependency on folder cube
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9984
diff changeset
   180
    filed_under = SubjectRelation('Folder', description=_('parent folder'))
593e63a68429 [server/test] Drop dependency on folder cube
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9984
diff changeset
   181
593e63a68429 [server/test] Drop dependency on folder cube
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9984
diff changeset
   182
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
   183
# 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
   184
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
   185
    __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
   186
    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
   187
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
# 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
   190
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
   191
    """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
   192
    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
   193
    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
   194
    """
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
   195
    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
   196
                  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
   197
    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
   198
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
   199
# 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
   200
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
   201
    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
   202
    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
   203
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
   204
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
   205
# 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
   206
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
   207
    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
   208
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
   209
# New
6163
407f54345687 [migration] fix add_relation_type() for symmetric relations
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 5575
diff changeset
   210
class same_as(RelationDefinition):
407f54345687 [migration] fix add_relation_type() for symmetric relations
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 5575
diff changeset
   211
    subject = ('Societe',)
407f54345687 [migration] fix add_relation_type() for symmetric relations
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 5575
diff changeset
   212
    object = 'ExternalUri'