web/test/data/schema.py
author Rémi Cardona <remi.cardona@logilab.fr>
Wed, 20 May 2015 16:33:01 +0200
changeset 10426 ce213d6858f1
parent 10302 7725396eb3df
child 10969 b4de8b1cc135
child 11122 fedcb69982af
permissions -rw-r--r--
[devtools] qunit: stop using deprecated assert functions equals -> equal same -> deepEqual Related to #5533333.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9213
312062f53981 [inlined form field] fix regression introduced in 3.16.4/570208f74a84. Closes #3064653
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9179
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
2636
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    18
5386
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    19
from yams.buildobjs import (EntityType, RelationDefinition, SubjectRelation,
2636
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    20
                            String, Int, Datetime, Boolean, Float)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    21
from yams.constraints import IntervalBoundConstraint
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    22
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    23
class Salesterm(EntityType):
9179
570208f74a84 [editcontrollers] Ensure entities are created in an order satisfying schema constraints. Closes #3031719
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7059
diff changeset
    24
    described_by_test = SubjectRelation('File', cardinality='1*',
570208f74a84 [editcontrollers] Ensure entities are created in an order satisfying schema constraints. Closes #3031719
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7059
diff changeset
    25
                                        composite='subject', inlined=True)
2636
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    26
    amount = Int(constraints=[IntervalBoundConstraint(0, 100)])
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    27
    reason = String(maxsize=20, vocabulary=[u'canceled', u'sold'])
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    28
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    29
class tags(RelationDefinition):
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    30
    subject = 'Tag'
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    31
    object = ('BlogEntry', 'CWUser')
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    32
5386
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    33
class checked_by(RelationDefinition):
2636
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    34
    subject = 'BlogEntry'
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    35
    object = 'CWUser'
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    36
    cardinality = '?*'
4078
3704c121624c api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2636
diff changeset
    37
    __permissions__ = {
2636
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    38
        'add': ('managers',),
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    39
        'read': ('managers', 'users'),
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    40
        'delete': ('managers',),
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    41
        }
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    42
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    43
class Personne(EntityType):
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    44
    nom    = String(fulltextindexed=True, required=True, maxsize=64)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    45
    prenom = String(fulltextindexed=True, maxsize=64)
9976
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9213
diff changeset
    46
    sexe   = String(maxsize=1, default='M',
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9213
diff changeset
    47
                    __permissions__={
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9213
diff changeset
    48
                        'read': ('managers', 'users', 'guests',),
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9213
diff changeset
    49
                        'add': ('managers', 'users'),
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9213
diff changeset
    50
                        'update': ('managers', )})
2636
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    51
    promo  = String(vocabulary=('bon','pasbon'))
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    52
    titre  = String(fulltextindexed=True, maxsize=128)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    53
    ass    = String(maxsize=128)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    54
    web    = String(maxsize=128)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    55
    tel    = Int()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    56
    fax    = Int()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    57
    datenaiss = Datetime()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    58
    test   = Boolean()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    59
    description = String()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    60
    salary = Float()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    61
    travaille = SubjectRelation('Societe')
5386
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    62
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    63
class connait(RelationDefinition):
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    64
    subject = 'CWUser'
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    65
    object = 'Personne'
2636
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    66
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    67
class Societe(EntityType):
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    68
    nom  = String(maxsize=64, fulltextindexed=True)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    69
    web  = String(maxsize=128)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    70
    type  = String(maxsize=128) # attribute in common with Note
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    71
    tel  = Int()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    72
    fax  = Int()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    73
    rncs = String(maxsize=128)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    74
    ad1  = String(maxsize=128)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    75
    ad2  = String(maxsize=128)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    76
    ad3  = String(maxsize=128)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    77
    cp   = String(maxsize=12)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    78
    ville= String(maxsize=32)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    79
6246
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    80
# enough relations to cover most reledit use cases
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    81
class Project(EntityType):
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    82
    title = String(maxsize=32, required=True, fulltextindexed=True)
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    83
    long_desc = SubjectRelation('Blog', composite='subject', cardinality='?*')
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    84
    manager = SubjectRelation('Personne', cardinality='?*')
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    85
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    86
class composite_card11_2ttypes(RelationDefinition):
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    87
    subject = 'Project'
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    88
    object = ('File', 'Blog')
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    89
    composite = 'subject'
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    90
    cardinality = '?*'
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    91
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    92
class Ticket(EntityType):
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    93
    title = String(maxsize=32, required=True, fulltextindexed=True)
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    94
    concerns = SubjectRelation('Project', composite='object')
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    95
10302
7725396eb3df [web/test] Drop folder cube dependency
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10167
diff changeset
    96
class Folder(EntityType):
7725396eb3df [web/test] Drop folder cube dependency
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10167
diff changeset
    97
    name = String(required=True)
7725396eb3df [web/test] Drop folder cube dependency
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10167
diff changeset
    98
    filed_under = SubjectRelation('Folder', description=_('parent folder'))
10167
de62952550d9 [web] Allow propagating 'klass' parameter on tree views recursively
Rémi Cardona <remi.cardona@logilab.fr>
parents: 9976
diff changeset
    99
de62952550d9 [web] Allow propagating 'klass' parameter on tree views recursively
Rémi Cardona <remi.cardona@logilab.fr>
parents: 9976
diff changeset
   100
class TreeNode(EntityType):
de62952550d9 [web] Allow propagating 'klass' parameter on tree views recursively
Rémi Cardona <remi.cardona@logilab.fr>
parents: 9976
diff changeset
   101
    name = String(required=True)
de62952550d9 [web] Allow propagating 'klass' parameter on tree views recursively
Rémi Cardona <remi.cardona@logilab.fr>
parents: 9976
diff changeset
   102
    parent = SubjectRelation('TreeNode', cardinality='?*')