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, RelationType, RelationDefinition, |
19 from yams.buildobjs import (EntityType, RelationType, RelationDefinition, |
20 SubjectRelation, RichString, String, Int, Boolean, Datetime) |
20 SubjectRelation, RichString, String, Int, Boolean, Datetime) |
21 from yams.constraints import SizeConstraint |
21 from yams.constraints import SizeConstraint |
22 from cubicweb.schema import (WorkflowableEntityType, RQLConstraint, |
22 from cubicweb.schema import (WorkflowableEntityType, |
|
23 RQLConstraint, RQLUniqueConstraint, |
23 ERQLExpression, RRQLExpression) |
24 ERQLExpression, RRQLExpression) |
24 |
25 |
25 class Affaire(WorkflowableEntityType): |
26 class Affaire(WorkflowableEntityType): |
26 __permissions__ = { |
27 __permissions__ = { |
27 'read': ('managers', |
28 'read': ('managers', |
91 'update': ('managers', ERQLExpression('X in_state S, S name "todo"')), |
92 'update': ('managers', ERQLExpression('X in_state S, S name "todo"')), |
92 }) |
93 }) |
93 |
94 |
94 migrated_from = SubjectRelation('Note') |
95 migrated_from = SubjectRelation('Note') |
95 attachment = SubjectRelation('File') |
96 attachment = SubjectRelation('File') |
96 inline1 = SubjectRelation('Affaire', inlined=True, cardinality='?*') |
97 inline1 = SubjectRelation('Affaire', inlined=True, cardinality='?*', |
|
98 constraints=[RQLUniqueConstraint('S type T, S inline1 A1, A1 todo_by C, ' |
|
99 'Y type T, Y inline1 A2, A2 todo_by C', |
|
100 'S,Y')]) |
97 todo_by = SubjectRelation('CWUser') |
101 todo_by = SubjectRelation('CWUser') |
98 |
102 |
99 class Personne(EntityType): |
103 class Personne(EntityType): |
100 __unique_together__ = [('nom', 'prenom', 'inline2')] |
104 __unique_together__ = [('nom', 'prenom', 'inline2')] |
101 nom = String(fulltextindexed=True, required=True, maxsize=64) |
105 nom = String(fulltextindexed=True, required=True, maxsize=64) |