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 from yams.buildobjs import (EntityType, RelationDefinition, String, SubjectRelation, |
|
19 ComputedRelation, Int) |
|
20 from cubicweb.schema import ERQLExpression |
|
21 |
|
22 |
|
23 class Person(EntityType): |
|
24 name = String() |
|
25 |
|
26 |
|
27 class Affaire(EntityType): |
|
28 __permissions__ = { |
|
29 'read': ('managers', |
|
30 ERQLExpression('X owned_by U'), ERQLExpression('X concerne S?, S owned_by U')), |
|
31 'add': ('managers', ERQLExpression('X concerne S, S owned_by U')), |
|
32 'update': ('managers', 'owners', ERQLExpression('X in_state S, S name in ("pitetre", "en cours")')), |
|
33 'delete': ('managers', 'owners', ERQLExpression('X concerne S, S owned_by U')), |
|
34 } |
|
35 ref = String(fulltextindexed=True, indexed=True, maxsize=16) |
|
36 documented_by = SubjectRelation('Card', cardinality='1*') |
|
37 concerne = SubjectRelation(('Societe', 'Note'), cardinality='1*') |
|
38 |
|
39 |
|
40 class Societe(EntityType): |
|
41 __permissions__ = { |
|
42 'read': ('managers', 'users', 'guests'), |
|
43 'update': ('managers', 'owners', ERQLExpression('U login L, X nom L')), |
|
44 'delete': ('managers', 'owners', ERQLExpression('U login L, X nom L')), |
|
45 'add': ('managers', 'users',) |
|
46 } |
|
47 nom = String() |
|
48 |
|
49 |
|
50 class Division(Societe): |
|
51 __specializes_schema__ = True |
|
52 |
|
53 |
|
54 class Note(EntityType): |
|
55 pass |
|
56 |
|
57 |
|
58 class require_permission(RelationDefinition): |
|
59 subject = ('Card', 'Note') |
|
60 object = 'CWPermission' |
|
61 |
|
62 |
|
63 class require_state(RelationDefinition): |
|
64 subject = 'CWPermission' |
|
65 object = 'State' |
|
66 |
|
67 |
|
68 class inlined_card(RelationDefinition): |
|
69 subject = 'Affaire' |
|
70 object = 'Card' |
|
71 inlined = True |
|
72 cardinality = '?*' |
|
73 |
|
74 class inlined_note(RelationDefinition): |
|
75 subject = 'Card' |
|
76 object = 'Note' |
|
77 inlined = True |
|
78 cardinality = '?*' |
|
79 |
|
80 class inlined_affaire(RelationDefinition): |
|
81 subject = 'Note' |
|
82 object = 'Affaire' |
|
83 inlined = True |
|
84 cardinality = '?*' |
|
85 |
|
86 class responsable(RelationDefinition): |
|
87 subject = 'Societe' |
|
88 object = 'CWUser' |
|
89 inlined = True |
|
90 cardinality = '1*' |
|
91 |
|
92 class Contribution(EntityType): |
|
93 code = Int() |
|
94 |
|
95 class ArtWork(EntityType): |
|
96 name = String() |
|
97 |
|
98 class Role(EntityType): |
|
99 name = String() |
|
100 |
|
101 class contributor(RelationDefinition): |
|
102 subject = 'Contribution' |
|
103 object = 'Person' |
|
104 cardinality = '1*' |
|
105 inlined = True |
|
106 |
|
107 class manifestation(RelationDefinition): |
|
108 subject = 'Contribution' |
|
109 object = 'ArtWork' |
|
110 |
|
111 class role(RelationDefinition): |
|
112 subject = 'Contribution' |
|
113 object = 'Role' |
|
114 |
|
115 class illustrator_of(ComputedRelation): |
|
116 rule = ('C is Contribution, C contributor S, C manifestation O, ' |
|
117 'C role R, R name "illustrator"') |
|
118 |
|
119 class participated_in(ComputedRelation): |
|
120 rule = 'S contributor O' |
|
121 |
|
122 class match(RelationDefinition): |
|
123 subject = 'ArtWork' |
|
124 object = 'Note' |
|