server/test/data/migratedapp/schema.py
changeset 9394 4b89ca0b11ad
parent 9299 c5eed908117d
child 9600 bde625698f44
equal deleted inserted replaced
9393:8266c8c375bb 9394:4b89ca0b11ad
     1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     3 #
     4 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     5 #
     5 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
    37     sujet = String(fulltextindexed=True,
    37     sujet = String(fulltextindexed=True,
    38                  constraints=[SizeConstraint(256)])
    38                  constraints=[SizeConstraint(256)])
    39     concerne = SubjectRelation('Societe')
    39     concerne = SubjectRelation('Societe')
    40     opt_attr = Bytes()
    40     opt_attr = Bytes()
    41 
    41 
    42 class concerne(RelationType):
    42 class Societe(WorkflowableEntityType):
    43     __permissions__ = {
    43     __permissions__ = {
    44         'read':   ('managers', 'users', 'guests'),
    44         'read': ('managers', 'users', 'guests'),
    45         'add':    ('managers', RRQLExpression('U has_update_permission S')),
    45         'update': ('managers', 'owners'),
    46         'delete': ('managers', RRQLExpression('O owned_by U')),
    46         'delete': ('managers', 'owners'),
       
    47         'add': ('managers', 'users',)
    47         }
    48         }
       
    49     nom  = String(maxsize=64, fulltextindexed=True)
       
    50     web  = String(maxsize=128)
       
    51     tel  = Int()
       
    52     fax  = Int()
       
    53     rncs = String(maxsize=128)
       
    54     ad1  = String(maxsize=128)
       
    55     ad2  = String(maxsize=128)
       
    56     ad3  = String(maxsize=128)
       
    57     cp   = String(maxsize=12)
       
    58     ville= String(maxsize=32)
    48 
    59 
       
    60 # Division and SubDivision are gone
       
    61 
       
    62 # New
    49 class Para(EntityType):
    63 class Para(EntityType):
    50     para = String(maxsize=512)
    64     para = String(maxsize=512)
    51     newattr = String()
    65     newattr = String()
    52     newinlined = SubjectRelation('Affaire', cardinality='?*', inlined=True)
    66     newinlined = SubjectRelation('Affaire', cardinality='?*', inlined=True)
    53     newnotinlined = SubjectRelation('Affaire', cardinality='?*')
    67     newnotinlined = SubjectRelation('Affaire', cardinality='?*')
    73     newstyledefaultdate = Date(default=dt.date(2013, 1, 1))
    87     newstyledefaultdate = Date(default=dt.date(2013, 1, 1))
    74     shortpara = String(maxsize=64, default='hop')
    88     shortpara = String(maxsize=64, default='hop')
    75     ecrit_par = SubjectRelation('Personne', constraints=[RQLConstraint('S concerne A, O concerne A')])
    89     ecrit_par = SubjectRelation('Personne', constraints=[RQLConstraint('S concerne A, O concerne A')])
    76     attachment = SubjectRelation('File')
    90     attachment = SubjectRelation('File')
    77 
    91 
    78 class Text(Para):
       
    79     __specializes_schema__ = True
       
    80     summary = String(maxsize=512)
       
    81 
       
    82 class ecrit_par(RelationType):
       
    83     __permissions__ = {'read':   ('managers', 'users', 'guests',),
       
    84                    'delete': ('managers', ),
       
    85                    'add':    ('managers',
       
    86                               RRQLExpression('O require_permission P, P name "add_note", '
       
    87                                              'U in_group G, P require_group G'),)
       
    88                    }
       
    89     inlined = True
       
    90     cardinality = '?*'
       
    91 
       
    92 
       
    93 class Folder2(EntityType):
       
    94     """folders are used to classify entities. They may be defined as a tree.
       
    95     When you include the Folder entity, all application specific entities
       
    96     may then be classified using the "filed_under" relation.
       
    97     """
       
    98     name = String(required=True, indexed=True, internationalizable=True,
       
    99                   constraints=[UniqueConstraint(), SizeConstraint(64)])
       
   100     description = RichString(fulltextindexed=True)
       
   101 
       
   102 class filed_under2(RelationDefinition):
       
   103     subject ='*'
       
   104     object = 'Folder2'
       
   105 
       
   106 
    92 
   107 class Personne(EntityType):
    93 class Personne(EntityType):
   108     __unique_together__ = [('nom', 'prenom', 'datenaiss')]
    94     __unique_together__ = [('nom', 'prenom', 'datenaiss')]
   109     nom    = String(fulltextindexed=True, required=True, maxsize=64)
    95     nom    = String(fulltextindexed=True, required=True, maxsize=64)
   110     prenom = String(fulltextindexed=True, maxsize=64)
    96     prenom = String(fulltextindexed=True, maxsize=64)
   122     travaille = SubjectRelation('Societe')
   108     travaille = SubjectRelation('Societe')
   123     concerne = SubjectRelation('Affaire')
   109     concerne = SubjectRelation('Affaire')
   124     concerne2 = SubjectRelation(('Affaire', 'Note'), cardinality='1*')
   110     concerne2 = SubjectRelation(('Affaire', 'Note'), cardinality='1*')
   125     connait = SubjectRelation('Personne', symmetric=True)
   111     connait = SubjectRelation('Personne', symmetric=True)
   126 
   112 
       
   113 class concerne(RelationType):
       
   114     __permissions__ = {
       
   115         'read':   ('managers', 'users', 'guests'),
       
   116         'add':    ('managers', RRQLExpression('U has_update_permission S')),
       
   117         'delete': ('managers', RRQLExpression('O owned_by U')),
       
   118         }
   127 
   119 
       
   120 # `Old` entity type is gonce
       
   121 # `comments` is gone
       
   122 # `fiche` is gone
       
   123 # `multisource_*` rdefs are gone
       
   124 # `see_also_*` rdefs are gone
       
   125 
       
   126 class evaluee(RelationDefinition):
       
   127     subject = ('Personne', 'CWUser', 'Societe')
       
   128     object = ('Note')
       
   129 
       
   130 class ecrit_par(RelationType):
       
   131     __permissions__ = {'read':   ('managers', 'users', 'guests',),
       
   132                    'delete': ('managers', ),
       
   133                    'add':    ('managers',
       
   134                               RRQLExpression('O require_permission P, P name "add_note", '
       
   135                                              'U in_group G, P require_group G'),)
       
   136                    }
       
   137     inlined = True
       
   138     cardinality = '?*'
       
   139 
       
   140 # `copain` rdef is gone
       
   141 # `tags` rdef is gone
       
   142 # `filed_under` rdef is gone
       
   143 # `require_permission` rdef is gone
       
   144 # `require_state` rdef is gone
       
   145 # `personne_composite` rdef is gone
       
   146 # `personne_inlined` rdef is gone
       
   147 # `login_user` rdef is gone
       
   148 # `ambiguous_inlined` rdef is gone
       
   149 
       
   150 # New
       
   151 class Text(Para):
       
   152     __specializes_schema__ = True
       
   153     summary = String(maxsize=512)
       
   154 
       
   155 
       
   156 # New
       
   157 class Folder2(EntityType):
       
   158     """folders are used to classify entities. They may be defined as a tree.
       
   159     When you include the Folder entity, all application specific entities
       
   160     may then be classified using the "filed_under" relation.
       
   161     """
       
   162     name = String(required=True, indexed=True, internationalizable=True,
       
   163                   constraints=[UniqueConstraint(), SizeConstraint(64)])
       
   164     description = RichString(fulltextindexed=True)
       
   165 
       
   166 # New
       
   167 class filed_under2(RelationDefinition):
       
   168     subject ='*'
       
   169     object = 'Folder2'
       
   170 
       
   171 
       
   172 # New
   128 class New(EntityType):
   173 class New(EntityType):
   129     new_name = String()
   174     new_name = String()
   130 
   175 
   131 class Societe(WorkflowableEntityType):
   176 # New
   132     __permissions__ = {
       
   133         'read': ('managers', 'users', 'guests'),
       
   134         'update': ('managers', 'owners'),
       
   135         'delete': ('managers', 'owners'),
       
   136         'add': ('managers', 'users',)
       
   137         }
       
   138     nom  = String(maxsize=64, fulltextindexed=True)
       
   139     web  = String(maxsize=128)
       
   140     tel  = Int()
       
   141     fax  = Int()
       
   142     rncs = String(maxsize=128)
       
   143     ad1  = String(maxsize=128)
       
   144     ad2  = String(maxsize=128)
       
   145     ad3  = String(maxsize=128)
       
   146     cp   = String(maxsize=12)
       
   147     ville= String(maxsize=32)
       
   148 
       
   149 class same_as(RelationDefinition):
   177 class same_as(RelationDefinition):
   150     subject = ('Societe',)
   178     subject = ('Societe',)
   151     object = 'ExternalUri'
   179     object = 'ExternalUri'
   152 
   180 
   153 class evaluee(RelationDefinition):
       
   154     subject = ('Personne', 'CWUser', 'Societe')
       
   155     object = ('Note')