4 :copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
4 :copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
7 """ |
7 """ |
8 from yams.buildobjs import (EntityType, RelationType, RelationDefinition, |
8 from yams.buildobjs import (EntityType, RelationType, RelationDefinition, |
9 SubjectRelation, ObjectRelation, |
9 SubjectRelation, RichString, String, Int, Boolean, Datetime) |
10 RichString, String, Int, Boolean, Datetime) |
|
11 from yams.constraints import SizeConstraint |
10 from yams.constraints import SizeConstraint |
12 from cubicweb.schema import (WorkflowableEntityType, RQLConstraint, |
11 from cubicweb.schema import (WorkflowableEntityType, RQLConstraint, |
13 ERQLExpression, RRQLExpression) |
12 ERQLExpression, RRQLExpression) |
14 |
13 |
15 class Affaire(WorkflowableEntityType): |
14 class Affaire(WorkflowableEntityType): |
62 class Division(Societe): |
61 class Division(Societe): |
63 __specializes_schema__ = True |
62 __specializes_schema__ = True |
64 |
63 |
65 class SubDivision(Division): |
64 class SubDivision(Division): |
66 __specializes_schema__ = True |
65 __specializes_schema__ = True |
67 travaille_subdivision = ObjectRelation('Personne') |
66 |
|
67 class travaille_subdivision(RelationDefinition): |
|
68 subject = 'Personne' |
|
69 object = 'SubDivision' |
68 |
70 |
69 from cubicweb.schemas.base import CWUser |
71 from cubicweb.schemas.base import CWUser |
70 CWUser.get_relations('login').next().fulltextindexed = True |
72 CWUser.get_relations('login').next().fulltextindexed = True |
71 |
73 |
72 class Note(WorkflowableEntityType): |
74 class Note(WorkflowableEntityType): |
73 date = String(maxsize=10) |
75 date = String(maxsize=10) |
74 type = String(maxsize=6) |
76 type = String(maxsize=6) |
75 para = String(maxsize=512) |
77 para = String(maxsize=512, |
|
78 __permissions__ = { |
|
79 'read': ('managers', 'users', 'guests'), |
|
80 'update': ('managers', ERQLExpression('X in_state S, S name "todo"')), |
|
81 }) |
76 |
82 |
77 migrated_from = SubjectRelation('Note') |
83 migrated_from = SubjectRelation('Note') |
78 attachment = SubjectRelation(('File', 'Image')) |
84 attachment = SubjectRelation(('File', 'Image')) |
79 inline1 = SubjectRelation('Affaire', inlined=True, cardinality='?*') |
85 inline1 = SubjectRelation('Affaire', inlined=True, cardinality='?*') |
80 todo_by = SubjectRelation('CWUser') |
86 todo_by = SubjectRelation('CWUser') |
89 ass = String(maxsize=128) |
95 ass = String(maxsize=128) |
90 web = String(maxsize=128) |
96 web = String(maxsize=128) |
91 tel = Int() |
97 tel = Int() |
92 fax = Int() |
98 fax = Int() |
93 datenaiss = Datetime() |
99 datenaiss = Datetime() |
94 test = Boolean() |
100 test = Boolean(__permissions__={ |
|
101 'read': ('managers', 'users', 'guests'), |
|
102 'update': ('managers',), |
|
103 }) |
95 description = String() |
104 description = String() |
96 firstname = String(fulltextindexed=True, maxsize=64) |
105 firstname = String(fulltextindexed=True, maxsize=64) |
97 |
106 |
98 travaille = SubjectRelation('Societe') |
|
99 concerne = SubjectRelation('Affaire') |
107 concerne = SubjectRelation('Affaire') |
100 connait = SubjectRelation('Personne') |
108 connait = SubjectRelation('Personne') |
101 inline2 = SubjectRelation('Affaire', inlined=True, cardinality='?*') |
109 inline2 = SubjectRelation('Affaire', inlined=True, cardinality='?*') |
102 comments = ObjectRelation('Comment') |
110 |
103 |
111 |
104 |
112 |
105 class fiche(RelationType): |
113 class connait(RelationType): |
|
114 symmetric = True |
|
115 |
|
116 class concerne(RelationType): |
|
117 __permissions__ = { |
|
118 'read': ('managers', 'users', 'guests'), |
|
119 'add': ('managers', RRQLExpression('U has_update_permission S')), |
|
120 'delete': ('managers', RRQLExpression('O owned_by U')), |
|
121 } |
|
122 |
|
123 class travaille(RelationDefinition): |
|
124 __permissions__ = { |
|
125 'read': ('managers', 'users', 'guests'), |
|
126 'add': ('managers', RRQLExpression('U has_update_permission S')), |
|
127 'delete': ('managers', RRQLExpression('O owned_by U')), |
|
128 } |
|
129 subject = 'Personne' |
|
130 object = 'Societe' |
|
131 |
|
132 class comments(RelationDefinition): |
|
133 subject = 'Comment' |
|
134 object = 'Personne' |
|
135 |
|
136 class fiche(RelationDefinition): |
106 inlined = True |
137 inlined = True |
107 subject = 'Personne' |
138 subject = 'Personne' |
108 object = 'Card' |
139 object = 'Card' |
109 cardinality = '??' |
140 cardinality = '??' |
110 |
141 |
111 class multisource_inlined_rel(RelationType): |
142 class multisource_inlined_rel(RelationDefinition): |
112 inlined = True |
143 inlined = True |
113 cardinality = '?*' |
144 cardinality = '?*' |
114 subject = ('Card', 'Note') |
145 subject = ('Card', 'Note') |
115 object = ('Affaire', 'Note') |
146 object = ('Affaire', 'Note') |
116 |
147 |
117 class ecrit_par(RelationType): |
|
118 inlined = True |
|
119 |
|
120 class connait(RelationType): |
|
121 symmetric = True |
|
122 |
|
123 class concerne(RelationType): |
|
124 __permissions__ = { |
|
125 'read': ('managers', 'users', 'guests'), |
|
126 'add': ('managers', RRQLExpression('U has_update_permission S')), |
|
127 'delete': ('managers', RRQLExpression('O owned_by U')), |
|
128 } |
|
129 |
|
130 class travaille(RelationType): |
|
131 __permissions__ = { |
|
132 'read': ('managers', 'users', 'guests'), |
|
133 'add': ('managers', RRQLExpression('U has_update_permission S')), |
|
134 'delete': ('managers', RRQLExpression('O owned_by U')), |
|
135 } |
|
136 |
|
137 class para(RelationType): |
|
138 __permissions__ = { |
|
139 'read': ('managers', 'users', 'guests'), |
|
140 'update': ('managers', ERQLExpression('X in_state S, S name "todo"')), |
|
141 } |
|
142 |
|
143 class test(RelationType): |
|
144 __permissions__ = {'read': ('managers', 'users', 'guests'), |
|
145 'update': ('managers',), |
|
146 } |
|
147 |
|
148 class multisource_rel(RelationDefinition): |
148 class multisource_rel(RelationDefinition): |
149 subject = ('Card', 'Note') |
149 subject = ('Card', 'Note') |
150 object = 'Note' |
150 object = 'Note' |
151 |
151 |
152 class multisource_crossed_rel(RelationDefinition): |
152 class multisource_crossed_rel(RelationDefinition): |