web/test/data/schema.py
author Florent Cayré <florent.cayre@logilab.fr>
Mon, 07 Dec 2015 11:58:17 +0100
changeset 11064 113e9da47afc
parent 11063 de20b0903d7d
child 11065 c7dbd10648e6
permissions -rw-r--r--
[edit controller] Cancel RQL queries to be performed on entities to be deleted Composite relation removal via the EditController trigger an entity removal. Changes on such a to-be-removed entity must be cancelled as they may trigger integrity errors before the deletion occurs. Closes #8529868.
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
11063
de20b0903d7d [edit controller] fix handling of removal of subentities from an edit form
Florent Cayré <florent.cayre@logilab.fr>
parents: 9976
diff changeset
    96
class Filesystem(EntityType):
de20b0903d7d [edit controller] fix handling of removal of subentities from an edit form
Florent Cayré <florent.cayre@logilab.fr>
parents: 9976
diff changeset
    97
    name = String()
de20b0903d7d [edit controller] fix handling of removal of subentities from an edit form
Florent Cayré <florent.cayre@logilab.fr>
parents: 9976
diff changeset
    98
de20b0903d7d [edit controller] fix handling of removal of subentities from an edit form
Florent Cayré <florent.cayre@logilab.fr>
parents: 9976
diff changeset
    99
class parent_fs(RelationDefinition):
de20b0903d7d [edit controller] fix handling of removal of subentities from an edit form
Florent Cayré <florent.cayre@logilab.fr>
parents: 9976
diff changeset
   100
    name = 'parent'
de20b0903d7d [edit controller] fix handling of removal of subentities from an edit form
Florent Cayré <florent.cayre@logilab.fr>
parents: 9976
diff changeset
   101
    subject = 'Directory'
de20b0903d7d [edit controller] fix handling of removal of subentities from an edit form
Florent Cayré <florent.cayre@logilab.fr>
parents: 9976
diff changeset
   102
    object = 'Filesystem'
de20b0903d7d [edit controller] fix handling of removal of subentities from an edit form
Florent Cayré <florent.cayre@logilab.fr>
parents: 9976
diff changeset
   103
de20b0903d7d [edit controller] fix handling of removal of subentities from an edit form
Florent Cayré <florent.cayre@logilab.fr>
parents: 9976
diff changeset
   104
class Directory(EntityType):
11064
113e9da47afc [edit controller] Cancel RQL queries to be performed on entities to be deleted
Florent Cayré <florent.cayre@logilab.fr>
parents: 11063
diff changeset
   105
    name = String(required=True)
11063
de20b0903d7d [edit controller] fix handling of removal of subentities from an edit form
Florent Cayré <florent.cayre@logilab.fr>
parents: 9976
diff changeset
   106
de20b0903d7d [edit controller] fix handling of removal of subentities from an edit form
Florent Cayré <florent.cayre@logilab.fr>
parents: 9976
diff changeset
   107
class parent_directory(RelationDefinition):
de20b0903d7d [edit controller] fix handling of removal of subentities from an edit form
Florent Cayré <florent.cayre@logilab.fr>
parents: 9976
diff changeset
   108
    name = 'parent'
de20b0903d7d [edit controller] fix handling of removal of subentities from an edit form
Florent Cayré <florent.cayre@logilab.fr>
parents: 9976
diff changeset
   109
    subject = 'Directory'
de20b0903d7d [edit controller] fix handling of removal of subentities from an edit form
Florent Cayré <florent.cayre@logilab.fr>
parents: 9976
diff changeset
   110
    object = 'Directory'
de20b0903d7d [edit controller] fix handling of removal of subentities from an edit form
Florent Cayré <florent.cayre@logilab.fr>
parents: 9976
diff changeset
   111
    composite = 'object'
de20b0903d7d [edit controller] fix handling of removal of subentities from an edit form
Florent Cayré <florent.cayre@logilab.fr>
parents: 9976
diff changeset
   112
7059
1d65b235549f [tests] Fix web test for windmill and forms
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6246
diff changeset
   113
# used by windmill for `test_edit_relation`
1d65b235549f [tests] Fix web test for windmill and forms
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6246
diff changeset
   114
from cubes.folder.schema import Folder