|
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 yams.buildobjs import (EntityType, RelationType, RelationDefinition, |
|
9 SubjectRelation, ObjectRelation, |
|
10 RichString, String, Int, Boolean, Datetime, Date) |
|
11 from yams.constraints import SizeConstraint, UniqueConstraint |
|
12 from cubicweb.schema import (WorkflowableEntityType, RQLConstraint, |
|
13 ERQLExpression, RRQLExpression) |
|
14 |
|
15 class Affaire(EntityType): |
|
16 permissions = { |
|
17 'read': ('managers', 'users', 'guests'), |
|
18 'add': ('managers', ERQLExpression('X concerne S, S owned_by U')), |
|
19 'update': ('managers', 'owners', ERQLExpression('X concerne S, S owned_by U')), |
|
20 'delete': ('managers', 'owners', ERQLExpression('X concerne S, S owned_by U')), |
|
21 } |
|
22 |
|
23 ref = String(fulltextindexed=True, indexed=True, |
|
24 constraints=[SizeConstraint(16)]) |
|
25 sujet = String(fulltextindexed=True, |
|
26 constraints=[SizeConstraint(256)]) |
|
27 concerne = SubjectRelation('Societe') |
|
28 |
|
29 class concerne(RelationType): |
|
30 permissions = { |
|
31 'read': ('managers', 'users', 'guests'), |
|
32 'add': ('managers', RRQLExpression('U has_update_permission S')), |
|
33 'delete': ('managers', RRQLExpression('O owned_by U')), |
|
34 } |
|
35 |
|
36 class Note(EntityType): |
|
37 permissions = {'read': ('managers', 'users', 'guests',), |
|
38 'update': ('managers', 'owners',), |
|
39 'delete': ('managers', ), |
|
40 'add': ('managers', |
|
41 ERQLExpression('X ecrit_part PE, U in_group G, ' |
|
42 'PE require_permission P, P name "add_note", ' |
|
43 'P require_group G'),)} |
|
44 |
|
45 date = Datetime() |
|
46 type = String(maxsize=1) |
|
47 whatever = Int() |
|
48 mydate = Date(default='TODAY') |
|
49 para = String(maxsize=512) |
|
50 shortpara = String(maxsize=64) |
|
51 ecrit_par = SubjectRelation('Personne', constraints=[RQLConstraint('S concerne A, O concerne A')]) |
|
52 attachment = SubjectRelation(('File', 'Image')) |
|
53 |
|
54 class ecrit_par(RelationType): |
|
55 permissions = {'read': ('managers', 'users', 'guests',), |
|
56 'delete': ('managers', ), |
|
57 'add': ('managers', |
|
58 RRQLExpression('O require_permission P, P name "add_note", ' |
|
59 'U in_group G, P require_group G'),) |
|
60 } |
|
61 inlined = True |
|
62 cardinality = '?*' |
|
63 |
|
64 class Folder2(EntityType): |
|
65 """folders are used to classify entities. They may be defined as a tree. |
|
66 When you include the Folder entity, all application specific entities |
|
67 may then be classified using the "filed_under" relation. |
|
68 """ |
|
69 name = String(required=True, indexed=True, internationalizable=True, |
|
70 constraints=[UniqueConstraint(), SizeConstraint(64)]) |
|
71 description = RichString(fulltextindexed=True) |
|
72 |
|
73 filed_under2 = ObjectRelation('*') |
|
74 |
|
75 |
|
76 class filed_under2(RelationType): |
|
77 """indicates that an entity is classified under a folder""" |
|
78 # is_about has been renamed into filed_under |
|
79 #//* is_about Folder |
|
80 #* filed_under Folder |
|
81 |
|
82 class Personne(EntityType): |
|
83 nom = String(fulltextindexed=True, required=True, maxsize=64) |
|
84 prenom = String(fulltextindexed=True, maxsize=64) |
|
85 sexe = String(maxsize=1, default='M') |
|
86 promo = String(vocabulary=('bon','pasbon')) |
|
87 titre = String(fulltextindexed=True, maxsize=128) |
|
88 adel = String(maxsize=128) |
|
89 ass = String(maxsize=128) |
|
90 web = String(maxsize=128) |
|
91 tel = Int() |
|
92 fax = Int() |
|
93 datenaiss = Datetime() |
|
94 test = Boolean() |
|
95 |
|
96 travaille = SubjectRelation('Societe') |
|
97 concerne = SubjectRelation('Affaire') |
|
98 concerne2 = SubjectRelation('Affaire') |
|
99 connait = SubjectRelation('Personne', symetric=True) |
|
100 |
|
101 class Societe(EntityType): |
|
102 permissions = { |
|
103 'read': ('managers', 'users', 'guests'), |
|
104 'update': ('managers', 'owners'), |
|
105 'delete': ('managers', 'owners'), |
|
106 'add': ('managers', 'users',) |
|
107 } |
|
108 |
|
109 nom = String(maxsize=64, fulltextindexed=True) |
|
110 web = String(maxsize=128) |
|
111 tel = Int() |
|
112 fax = Int() |
|
113 rncs = String(maxsize=128) |
|
114 ad1 = String(maxsize=128) |
|
115 ad2 = String(maxsize=128) |
|
116 ad3 = String(maxsize=128) |
|
117 cp = String(maxsize=12) |
|
118 ville= String(maxsize=32) |
|
119 |
|
120 in_state = SubjectRelation('State', cardinality='?*') |
|
121 |
|
122 class evaluee(RelationDefinition): |
|
123 subject = ('Personne', 'CWUser', 'Societe') |
|
124 object = ('Note') |