cubicweb/web/test/data/schema.py
changeset 11057 0b59724cb3f2
parent 10969 b4de8b1cc135
child 11129 97095348b3ee
equal deleted inserted replaced
11052:058bb3dc685f 11057:0b59724cb3f2
       
     1 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
       
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
       
     3 #
       
     4 # This file is part of CubicWeb.
       
     5 #
       
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
       
     7 # terms of the GNU Lesser General Public License as published by the Free
       
     8 # Software Foundation, either version 2.1 of the License, or (at your option)
       
     9 # any later version.
       
    10 #
       
    11 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT
       
    12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
       
    13 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
       
    14 # details.
       
    15 #
       
    16 # You should have received a copy of the GNU Lesser General Public License along
       
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
       
    18 
       
    19 from yams.buildobjs import (EntityType, RelationDefinition, SubjectRelation,
       
    20                             String, Int, Datetime, Boolean, Float)
       
    21 from yams.constraints import IntervalBoundConstraint
       
    22 
       
    23 from cubicweb import _
       
    24 
       
    25 
       
    26 class Salesterm(EntityType):
       
    27     described_by_test = SubjectRelation('File', cardinality='1*',
       
    28                                         composite='subject', inlined=True)
       
    29     amount = Int(constraints=[IntervalBoundConstraint(0, 100)])
       
    30     reason = String(maxsize=20, vocabulary=[u'canceled', u'sold'])
       
    31 
       
    32 class tags(RelationDefinition):
       
    33     subject = 'Tag'
       
    34     object = ('BlogEntry', 'CWUser')
       
    35 
       
    36 class checked_by(RelationDefinition):
       
    37     subject = 'BlogEntry'
       
    38     object = 'CWUser'
       
    39     cardinality = '?*'
       
    40     __permissions__ = {
       
    41         'add': ('managers',),
       
    42         'read': ('managers', 'users'),
       
    43         'delete': ('managers',),
       
    44         }
       
    45 
       
    46 class Personne(EntityType):
       
    47     nom    = String(fulltextindexed=True, required=True, maxsize=64)
       
    48     prenom = String(fulltextindexed=True, maxsize=64)
       
    49     sexe   = String(maxsize=1, default='M',
       
    50                     __permissions__={
       
    51                         'read': ('managers', 'users', 'guests',),
       
    52                         'add': ('managers', 'users'),
       
    53                         'update': ('managers', )})
       
    54     promo  = String(vocabulary=('bon','pasbon'))
       
    55     titre  = String(fulltextindexed=True, maxsize=128)
       
    56     ass    = String(maxsize=128)
       
    57     web    = String(maxsize=128)
       
    58     tel    = Int()
       
    59     fax    = Int()
       
    60     datenaiss = Datetime()
       
    61     test   = Boolean()
       
    62     description = String()
       
    63     salary = Float()
       
    64     travaille = SubjectRelation('Societe')
       
    65 
       
    66 class connait(RelationDefinition):
       
    67     subject = 'CWUser'
       
    68     object = 'Personne'
       
    69 
       
    70 class Societe(EntityType):
       
    71     nom  = String(maxsize=64, fulltextindexed=True)
       
    72     web  = String(maxsize=128)
       
    73     type  = String(maxsize=128) # attribute in common with Note
       
    74     tel  = Int()
       
    75     fax  = Int()
       
    76     rncs = String(maxsize=128)
       
    77     ad1  = String(maxsize=128)
       
    78     ad2  = String(maxsize=128)
       
    79     ad3  = String(maxsize=128)
       
    80     cp   = String(maxsize=12)
       
    81     ville= String(maxsize=32)
       
    82 
       
    83 # enough relations to cover most reledit use cases
       
    84 class Project(EntityType):
       
    85     title = String(maxsize=32, required=True, fulltextindexed=True)
       
    86     long_desc = SubjectRelation('Blog', composite='subject', cardinality='?*')
       
    87     manager = SubjectRelation('Personne', cardinality='?*')
       
    88 
       
    89 class composite_card11_2ttypes(RelationDefinition):
       
    90     subject = 'Project'
       
    91     object = ('File', 'Blog')
       
    92     composite = 'subject'
       
    93     cardinality = '?*'
       
    94 
       
    95 class Ticket(EntityType):
       
    96     title = String(maxsize=32, required=True, fulltextindexed=True)
       
    97     concerns = SubjectRelation('Project', composite='object')
       
    98 
       
    99 class Folder(EntityType):
       
   100     name = String(required=True)
       
   101     filed_under = SubjectRelation('Folder', description=_('parent folder'))
       
   102 
       
   103 class TreeNode(EntityType):
       
   104     name = String(required=True)
       
   105     parent = SubjectRelation('TreeNode', cardinality='?*')