hooks/test/data/schema.py
changeset 11057 0b59724cb3f2
parent 11052 058bb3dc685f
child 11058 23eb30449fe5
equal deleted inserted replaced
11052:058bb3dc685f 11057:0b59724cb3f2
     1 # copyright 2003-2014 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 (RelationDefinition, RelationType, EntityType,
       
    20                             String, Datetime, Int)
       
    21 from yams.reader import context
       
    22 
       
    23 from cubicweb.schema import ERQLExpression
       
    24 
       
    25 from cubicweb import _
       
    26 
       
    27 class friend(RelationDefinition):
       
    28     subject = ('CWUser', 'CWGroup')
       
    29     object = ('CWUser', 'CWGroup')
       
    30     symmetric = True
       
    31 
       
    32 class Folder(EntityType):
       
    33     name = String()
       
    34 
       
    35 class parent(RelationDefinition):
       
    36     subject = 'Folder'
       
    37     object = 'Folder'
       
    38     composite = 'object'
       
    39     cardinality = '?*'
       
    40 
       
    41 class children(RelationDefinition):
       
    42     subject = 'Folder'
       
    43     object = 'Folder'
       
    44     composite = 'subject'
       
    45 
       
    46 
       
    47 class Email(EntityType):
       
    48     """electronic mail"""
       
    49     subject   = String(fulltextindexed=True)
       
    50     date      = Datetime(description=_('UTC time on which the mail was sent'))
       
    51     messageid = String(required=True, indexed=True)
       
    52     headers   = String(description=_('raw headers'))
       
    53 
       
    54 
       
    55 
       
    56 class EmailPart(EntityType):
       
    57     """an email attachment"""
       
    58     __permissions__ = {
       
    59         'read':   ('managers', 'users', 'guests',), # XXX if E parts X, U has_read_permission E
       
    60         'add':    ('managers', ERQLExpression('E parts X, U has_update_permission E'),),
       
    61         'delete': ('managers', ERQLExpression('E parts X, U has_update_permission E')),
       
    62         'update': ('managers', 'owners',),
       
    63         }
       
    64 
       
    65     content  = String(fulltextindexed=True)
       
    66     content_format = String(required=True, maxsize=50)
       
    67     ordernum = Int(required=True)
       
    68 
       
    69 
       
    70 class parts(RelationType):
       
    71     subject = 'Email'
       
    72     object = 'EmailPart'
       
    73     cardinality = '*1'
       
    74     composite = 'subject'
       
    75     fulltext_container = 'subject'
       
    76 
       
    77 class sender(RelationDefinition):
       
    78     subject = 'Email'
       
    79     object = 'EmailAddress'
       
    80     cardinality = '?*'
       
    81     inlined = True
       
    82 
       
    83 class recipients(RelationDefinition):
       
    84     subject = 'Email'
       
    85     object = 'EmailAddress'