class evaluee(RelationDefinition): subject = ('Personne', 'CWUser', 'Societe') object = ('Note') constraints = [ RQLVocabularyConstraint('S created_by U'), RQLVocabularyConstraint('S owned_by U'), ]
class Personne(EntityType): nom = String(required=True) prenom = String() type = String() travaille = SubjectRelation('Societe') evaluee = SubjectRelation(('Note', 'Personne')) connait = SubjectRelation( 'Personne', symmetric=True, constraints=[ RQLConstraint('NOT S identity O'), # conflicting constraints, see cw_unrelated_rql tests in # unittest_entity.py RQLVocabularyConstraint('NOT (S connait P, P nom "toto")'), RQLVocabularyConstraint('S travaille P, P nom "tutu"') ]) actionnaire = SubjectRelation( 'Societe', cardinality='??', constraints=[RQLConstraint('NOT EXISTS(O contrat_exclusif S)')]) dirige = SubjectRelation('Societe', cardinality='??', constraints=[RQLConstraint('S actionnaire O')]) associe = SubjectRelation( 'Personne', cardinality='?*', constraints=[RQLConstraint('S actionnaire SOC, O actionnaire SOC')])
class travaille(RelationDefinition): __permissions__ = { 'read': ('managers', 'users', 'guests'), 'add': ('managers', RRQLExpression('U has_update_permission S')), 'delete': ('managers', RRQLExpression('O owned_by U')), } subject = 'Personne' object = 'Societe' constraints = [RQLVocabularyConstraint('S owned_by U'), RQLVocabularyConstraint('S created_by U')]
class FabriqueAvecMat(EntityType): type_mesure = String(vocabulary=_TYPES_MESURE, fulltextindexed=True) quantite = Float() unite = String(maxsize=255, fulltextindexed=True) provenance_mesure = String(maxsize=255, fulltextindexed=True) conversion = Float() usage = String(fulltextindexed=True) achat_matiere = SubjectRelation('AchatMateriaux', cardinality='1*', constraints = [RQLVocabularyConstraint('T1 achat O, AF avec_mat S, T2 achat AF, T1 compte C1, T2 compte C2, C1 identity C2')] )