test/data/schema.py
branchstable
changeset 7425 7e9d1d6fcba7
parent 7154 5e2f93b88d86
child 7973 64639bc94e25
equal deleted inserted replaced
7424:2c72bfbbf1a3 7425:7e9d1d6fcba7
    16 # You should have received a copy of the GNU Lesser General Public License along
    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/>.
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    18 
    18 
    19 from yams.buildobjs import (EntityType, String, SubjectRelation,
    19 from yams.buildobjs import (EntityType, String, SubjectRelation,
    20                             RelationDefinition)
    20                             RelationDefinition)
       
    21 
    21 from cubicweb.schema import (WorkflowableEntityType,
    22 from cubicweb.schema import (WorkflowableEntityType,
    22                              RQLConstraint, RQLVocabularyConstraint)
    23                              RQLConstraint, RQLVocabularyConstraint)
       
    24 
    23 
    25 
    24 class Personne(EntityType):
    26 class Personne(EntityType):
    25     nom = String(required=True)
    27     nom = String(required=True)
    26     prenom = String()
    28     prenom = String()
    27     type = String()
    29     type = String()
    34             # conflicting constraints, see cw_unrelated_rql tests in
    36             # conflicting constraints, see cw_unrelated_rql tests in
    35             # unittest_entity.py
    37             # unittest_entity.py
    36             RQLVocabularyConstraint('NOT (S connait P, P nom "toto")'),
    38             RQLVocabularyConstraint('NOT (S connait P, P nom "toto")'),
    37             RQLVocabularyConstraint('S travaille P, P nom "tutu"')])
    39             RQLVocabularyConstraint('S travaille P, P nom "tutu"')])
    38 
    40 
       
    41 
    39 class Societe(EntityType):
    42 class Societe(EntityType):
    40     nom = String()
    43     nom = String()
    41     evaluee = SubjectRelation('Note')
    44     evaluee = SubjectRelation('Note')
       
    45     fournit = SubjectRelation(('Service', 'Produit'), cardinality='1*')
       
    46 
       
    47 
       
    48 class Service(EntityType):
       
    49     fabrique_par = SubjectRelation('Personne', cardinality='1*')
       
    50 
       
    51 
       
    52 class Produit(EntityType):
       
    53     fabrique_par = SubjectRelation('Usine', cardinality='1*')
       
    54 
       
    55 
       
    56 class Usine(EntityType):
       
    57     lieu = String(required=True)
       
    58 
    42 
    59 
    43 class Note(EntityType):
    60 class Note(EntityType):
    44     type = String()
    61     type = String()
    45     ecrit_par = SubjectRelation('Personne')
    62     ecrit_par = SubjectRelation('Personne')
    46 
    63 
       
    64 
    47 class SubNote(Note):
    65 class SubNote(Note):
    48     __specializes_schema__ = True
    66     __specializes_schema__ = True
    49     description = String()
    67     description = String()
    50 
    68 
       
    69 
    51 class tags(RelationDefinition):
    70 class tags(RelationDefinition):
    52     subject = 'Tag'
    71     subject = 'Tag'
    53     object = ('Personne', 'Note')
    72     object = ('Personne', 'Note')
       
    73 
    54 
    74 
    55 class evaluee(RelationDefinition):
    75 class evaluee(RelationDefinition):
    56     subject = 'CWUser'
    76     subject = 'CWUser'
    57     object = 'Note'
    77     object = 'Note'
    58 
    78 
    59 
    79 
    60 class StateFull(WorkflowableEntityType):
    80 class StateFull(WorkflowableEntityType):
    61     name = String()
    81     name = String()
    62 
       
    63