|
1 """ |
|
2 |
|
3 :organization: Logilab |
|
4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
|
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
|
6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
|
7 """ |
|
8 from cubicweb.schema import format_constraint |
|
9 |
|
10 class Affaire(WorkflowableEntityType): |
|
11 permissions = { |
|
12 'read': ('managers', |
|
13 ERQLExpression('X owned_by U'), ERQLExpression('X concerne S?, S owned_by U')), |
|
14 'add': ('managers', ERQLExpression('X concerne S, S owned_by U')), |
|
15 'update': ('managers', 'owners', ERQLExpression('X in_state S, S name in ("pitetre", "en cours")')), |
|
16 'delete': ('managers', 'owners', ERQLExpression('X concerne S, S owned_by U')), |
|
17 } |
|
18 |
|
19 ref = String(fulltextindexed=True, indexed=True, |
|
20 constraints=[SizeConstraint(16)]) |
|
21 sujet = String(fulltextindexed=True, |
|
22 constraints=[SizeConstraint(256)]) |
|
23 descr_format = String(meta=True, internationalizable=True, |
|
24 default='text/rest', constraints=[format_constraint]) |
|
25 descr = String(fulltextindexed=True, |
|
26 description=_('more detailed description')) |
|
27 |
|
28 duration = Int() |
|
29 invoiced = Int() |
|
30 |
|
31 depends_on = SubjectRelation('Affaire') |
|
32 require_permission = SubjectRelation('CWPermission') |
|
33 concerne = SubjectRelation(('Societe', 'Note')) |
|
34 todo_by = SubjectRelation('Personne') |
|
35 documented_by = SubjectRelation('Card') |
|
36 |
|
37 |
|
38 class Societe(EntityType): |
|
39 permissions = { |
|
40 'read': ('managers', 'users', 'guests'), |
|
41 'update': ('managers', 'owners', ERQLExpression('U login L, X nom L')), |
|
42 'delete': ('managers', 'owners', ERQLExpression('U login L, X nom L')), |
|
43 'add': ('managers', 'users',) |
|
44 } |
|
45 |
|
46 nom = String(maxsize=64, fulltextindexed=True) |
|
47 web = String(maxsize=128) |
|
48 type = String(maxsize=128) # attribute in common with Note |
|
49 tel = Int() |
|
50 fax = Int() |
|
51 rncs = String(maxsize=128) |
|
52 ad1 = String(maxsize=128) |
|
53 ad2 = String(maxsize=128) |
|
54 ad3 = String(maxsize=128) |
|
55 cp = String(maxsize=12) |
|
56 ville= String(maxsize=32) |
|
57 |
|
58 |
|
59 class Division(Societe): |
|
60 __specializes_schema__ = True |
|
61 |
|
62 class SubDivision(Division): |
|
63 __specializes_schema__ = True |
|
64 travaille_subdivision = ObjectRelation('Personne') |
|
65 |
|
66 _euser = import_schema('base').CWUser |
|
67 _euser.__relations__[0].fulltextindexed = True |
|
68 |
|
69 class Note(EntityType): |
|
70 date = String(maxsize=10) |
|
71 type = String(maxsize=6) |
|
72 para = String(maxsize=512) |
|
73 |
|
74 migrated_from = SubjectRelation('Note') |
|
75 attachment = SubjectRelation(('File', 'Image')) |
|
76 inline1 = SubjectRelation('Affaire', inlined=True) |
|
77 todo_by = SubjectRelation('CWUser') |
|
78 |
|
79 class Personne(EntityType): |
|
80 nom = String(fulltextindexed=True, required=True, maxsize=64) |
|
81 prenom = String(fulltextindexed=True, maxsize=64) |
|
82 sexe = String(maxsize=1, default='M') |
|
83 promo = String(vocabulary=('bon','pasbon')) |
|
84 titre = String(fulltextindexed=True, maxsize=128) |
|
85 adel = String(maxsize=128) |
|
86 ass = String(maxsize=128) |
|
87 web = String(maxsize=128) |
|
88 tel = Int() |
|
89 fax = Int() |
|
90 datenaiss = Datetime() |
|
91 test = Boolean() |
|
92 description = String() |
|
93 firstname = String(fulltextindexed=True, maxsize=64) |
|
94 |
|
95 travaille = SubjectRelation('Societe') |
|
96 concerne = SubjectRelation('Affaire') |
|
97 connait = SubjectRelation('Personne') |
|
98 inline2 = SubjectRelation('Affaire', inlined=True) |
|
99 comments = ObjectRelation('Comment') |
|
100 |
|
101 |
|
102 class fiche(RelationType): |
|
103 inlined = True |
|
104 subject = 'Personne' |
|
105 object = 'Card' |
|
106 cardinality = '??' |
|
107 |
|
108 class multisource_inlined_rel(RelationType): |
|
109 inlined = True |
|
110 cardinality = '?*' |
|
111 subject = ('Card', 'Note') |
|
112 object = ('Affaire', 'Note') |
|
113 |
|
114 class ecrit_par(RelationType): |
|
115 inlined = True |
|
116 |
|
117 class connait(RelationType): |
|
118 symetric = True |
|
119 |
|
120 class concerne(RelationType): |
|
121 permissions = { |
|
122 'read': ('managers', 'users', 'guests'), |
|
123 'add': ('managers', RRQLExpression('U has_update_permission S')), |
|
124 'delete': ('managers', RRQLExpression('O owned_by U')), |
|
125 } |
|
126 |
|
127 class travaille(RelationType): |
|
128 permissions = { |
|
129 'read': ('managers', 'users', 'guests'), |
|
130 'add': ('managers', RRQLExpression('U has_update_permission S')), |
|
131 'delete': ('managers', RRQLExpression('O owned_by U')), |
|
132 } |
|
133 |
|
134 class para(AttributeRelationType): |
|
135 permissions = { |
|
136 'read': ('managers', 'users', 'guests'), |
|
137 'add': ('managers', ERQLExpression('X in_state S, S name "todo"')), |
|
138 'delete': ('managers', ERQLExpression('X in_state S, S name "todo"')), |
|
139 } |
|
140 |
|
141 class test(AttributeRelationType): |
|
142 permissions = {'read': ('managers', 'users', 'guests'), |
|
143 'delete': ('managers',), |
|
144 'add': ('managers',)} |
|
145 |
|
146 |
|
147 class in_state(RelationDefinition): |
|
148 subject = 'Note' |
|
149 object = 'State' |
|
150 cardinality = '1*' |
|
151 constraints=[RQLConstraint('S is ET, O state_of ET')] |
|
152 |
|
153 class wf_info_for(RelationDefinition): |
|
154 subject = 'TrInfo' |
|
155 object = 'Note' |
|
156 cardinality = '1*' |
|
157 |
|
158 class multisource_rel(RelationDefinition): |
|
159 subject = ('Card', 'Note') |
|
160 object = 'Note' |
|
161 |
|
162 class multisource_crossed_rel(RelationDefinition): |
|
163 subject = ('Card', 'Note') |
|
164 object = 'Note' |
|
165 |
|
166 |
|
167 class see_also(RelationDefinition): |
|
168 subject = ('Bookmark', 'Note') |
|
169 object = ('Bookmark', 'Note') |
|
170 |
|
171 class evaluee(RelationDefinition): |
|
172 subject = ('Personne', 'CWUser', 'Societe') |
|
173 object = ('Note') |
|
174 |
|
175 class ecrit_par_1(RelationDefinition): |
|
176 name = 'ecrit_par' |
|
177 subject = 'Note' |
|
178 object ='Personne' |
|
179 constraints = [RQLConstraint('E concerns P, X version_of P')] |
|
180 |
|
181 class ecrit_par_2(RelationDefinition): |
|
182 name = 'ecrit_par' |
|
183 subject = 'Note' |
|
184 object ='CWUser' |
|
185 |
|
186 class see_also(RelationDefinition): |
|
187 subject = object = 'Folder' |
|
188 |
|
189 |
|
190 class copain(RelationDefinition): |
|
191 subject = object = 'CWUser' |
|
192 |
|
193 class tags(RelationDefinition): |
|
194 subject = 'Tag' |
|
195 object = ('CWUser', 'CWGroup', 'State', 'Note', 'Card', 'Affaire') |
|
196 |
|
197 class filed_under(RelationDefinition): |
|
198 subject = ('Note', 'Affaire') |
|
199 object = 'Folder' |
|
200 |
|
201 class require_permission(RelationDefinition): |
|
202 subject = ('Card', 'Note') |
|
203 object = 'CWPermission' |
|
204 |
|
205 class require_state(RelationDefinition): |
|
206 subject = 'CWPermission' |
|
207 object = 'State' |