cubicweb/web/test/data/schema.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Sat, 16 Jan 2016 13:48:51 +0100
changeset 11057 0b59724cb3f2
parent 10969 web/test/data/schema.py@b4de8b1cc135
child 11129 97095348b3ee
permissions -rw-r--r--
Reorganize source tree to have a "cubicweb" top-level package Basically: mkdir cubicweb hg mv *.py -X setup.py cubicweb hg mv dataimport devtools entities etwist ext hooks i18n misc schemas server skeleton sobjects test web wsgi cubicweb Other changes: * adjust path to cubicweb-ctl in devtools tests * update setup.py to avoid importing __pkginfo__ (exec it instead), replace os.path.walk by os.walk and prepend `modname` here and there * update tox.ini to account for new test locations * update doc/conf.py so that it still finds __pkginfo__.py and CWDIR in doc/Makefile
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
10969
b4de8b1cc135 Use cubicweb._
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
    23
from cubicweb import _
b4de8b1cc135 Use cubicweb._
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
    24
b4de8b1cc135 Use cubicweb._
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
    25
2636
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    26
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
    27
    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
    28
                                        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
    29
    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
    30
    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
    31
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    32
class tags(RelationDefinition):
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    33
    subject = 'Tag'
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    34
    object = ('BlogEntry', 'CWUser')
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    35
5386
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    36
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
    37
    subject = 'BlogEntry'
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    38
    object = 'CWUser'
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    39
    cardinality = '?*'
4078
3704c121624c api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2636
diff changeset
    40
    __permissions__ = {
2636
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    41
        'add': ('managers',),
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    42
        'read': ('managers', 'users'),
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    43
        'delete': ('managers',),
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    44
        }
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    45
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    46
class Personne(EntityType):
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    47
    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
    48
    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
    49
    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
    50
                    __permissions__={
457efde98629 [views] Display attributes in entity creation form based on "add" permission
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 9213
diff changeset
    51
                        '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
    52
                        '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
    53
                        'update': ('managers', )})
2636
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    54
    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
    55
    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
    56
    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
    57
    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
    58
    tel    = Int()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    59
    fax    = Int()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    60
    datenaiss = Datetime()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    61
    test   = Boolean()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    62
    description = String()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    63
    salary = Float()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    64
    travaille = SubjectRelation('Societe')
5386
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    65
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    66
class connait(RelationDefinition):
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    67
    subject = 'CWUser'
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    68
    object = 'Personne'
2636
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    69
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    70
class Societe(EntityType):
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    71
    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
    72
    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
    73
    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
    74
    tel  = Int()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    75
    fax  = Int()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    76
    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
    77
    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
    78
    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
    79
    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
    80
    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
    81
    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
    82
6246
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    83
# enough relations to cover most reledit use cases
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    84
class Project(EntityType):
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    85
    title = String(maxsize=32, required=True, fulltextindexed=True)
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    86
    long_desc = SubjectRelation('Blog', composite='subject', cardinality='?*')
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    87
    manager = SubjectRelation('Personne', cardinality='?*')
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    88
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    89
class composite_card11_2ttypes(RelationDefinition):
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    90
    subject = 'Project'
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    91
    object = ('File', 'Blog')
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    92
    composite = 'subject'
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    93
    cardinality = '?*'
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    94
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    95
class Ticket(EntityType):
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    96
    title = String(maxsize=32, required=True, fulltextindexed=True)
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    97
    concerns = SubjectRelation('Project', composite='object')
62e25fac41cd [views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5426
diff changeset
    98
10302
7725396eb3df [web/test] Drop folder cube dependency
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10167
diff changeset
    99
class Folder(EntityType):
7725396eb3df [web/test] Drop folder cube dependency
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10167
diff changeset
   100
    name = String(required=True)
7725396eb3df [web/test] Drop folder cube dependency
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 10167
diff changeset
   101
    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
   102
de62952550d9 [web] Allow propagating 'klass' parameter on tree views recursively
Rémi Cardona <remi.cardona@logilab.fr>
parents: 9976
diff changeset
   103
class TreeNode(EntityType):
de62952550d9 [web] Allow propagating 'klass' parameter on tree views recursively
Rémi Cardona <remi.cardona@logilab.fr>
parents: 9976
diff changeset
   104
    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
   105
    parent = SubjectRelation('TreeNode', cardinality='?*')