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 __docformat__ = "restructuredtext en" |
8 __docformat__ = "restructuredtext en" |
9 _ = unicode |
9 _ = unicode |
10 |
10 |
11 from yams.buildobjs import (EntityType, RelationType, SubjectRelation, |
11 from yams.buildobjs import (EntityType, RelationType, RelationDefinition, |
12 RichString, String, Boolean, Int) |
12 SubjectRelation, RichString, String, Boolean, Int) |
13 from cubicweb.schema import RQLConstraint |
13 from cubicweb.schema import RQLConstraint |
14 from cubicweb.schemas import META_ETYPE_PERMS, META_RTYPE_PERMS |
14 from cubicweb.schemas import META_ETYPE_PERMS, META_RTYPE_PERMS |
15 |
15 |
16 # not restricted since as "is" is handled as other relations, guests need |
16 # not restricted since as "is" is handled as other relations, guests need |
17 # access to this |
17 # access to this |
193 class cstrtype(RelationType): |
193 class cstrtype(RelationType): |
194 """constraint factory""" |
194 """constraint factory""" |
195 __permissions__ = META_RTYPE_PERMS |
195 __permissions__ = META_RTYPE_PERMS |
196 inlined = True |
196 inlined = True |
197 |
197 |
198 class read_permission(RelationType): |
198 |
199 """grant permission to read entity or relation through a group or rql |
199 class read_permission_cwgroup(RelationDefinition): |
200 expression |
200 """groups allowed to read entities/relations of this type""" |
201 """ |
201 __permissions__ = META_RTYPE_PERMS |
202 __permissions__ = META_RTYPE_PERMS |
202 name = 'read_permission' |
203 subject = ('CWEType', 'CWAttribute', 'CWRelation') |
203 subject = ('CWEType', 'CWAttribute', 'CWRelation') |
204 object = ('CWGroup', 'RQLExpression') |
204 object = 'CWGroup' |
|
205 cardinality = '**' |
|
206 |
|
207 class add_permission_cwgroup(RelationDefinition): |
|
208 """groups allowed to add entities/relations of this type""" |
|
209 __permissions__ = META_RTYPE_PERMS |
|
210 name = 'add_permission' |
|
211 subject = ('CWEType', 'CWRelation') |
|
212 object = 'CWGroup' |
|
213 cardinality = '**' |
|
214 |
|
215 class delete_permission_cwgroup(RelationDefinition): |
|
216 """groups allowed to delete entities/relations of this type""" |
|
217 __permissions__ = META_RTYPE_PERMS |
|
218 name = 'delete_permission' |
|
219 subject = ('CWEType', 'CWRelation') |
|
220 object = 'CWGroup' |
|
221 cardinality = '**' |
|
222 |
|
223 class update_permission_cwgroup(RelationDefinition): |
|
224 """groups allowed to update entities/relations of this type""" |
|
225 __permissions__ = META_RTYPE_PERMS |
|
226 name = 'update_permission' |
|
227 subject = ('CWEType', 'CWAttribute') |
|
228 object = 'CWGroup' |
|
229 cardinality = '**' |
|
230 |
|
231 class read_permission_rqlexpr(RelationDefinition): |
|
232 """rql expression allowing to read entities/relations of this type""" |
|
233 __permissions__ = META_RTYPE_PERMS |
|
234 name = 'read_permission' |
|
235 subject = ('CWEType', 'CWAttribute', 'CWRelation') |
|
236 object = 'RQLExpression' |
205 cardinality = '*?' |
237 cardinality = '*?' |
206 composite = 'subject' |
238 composite = 'subject' |
207 |
239 |
208 class add_permission(RelationType): |
240 class add_permission_rqlexpr(RelationDefinition): |
209 """grant permission to add entity or relation through a group or rql |
241 """rql expression allowing to add entities/relations of this type""" |
210 expression |
242 __permissions__ = META_RTYPE_PERMS |
211 """ |
243 name = 'add_permission' |
212 __permissions__ = META_RTYPE_PERMS |
|
213 subject = ('CWEType', 'CWRelation') |
244 subject = ('CWEType', 'CWRelation') |
214 object = ('CWGroup', 'RQLExpression') |
245 object = 'RQLExpression' |
215 cardinality = '*?' |
246 cardinality = '*?' |
216 composite = 'subject' |
247 composite = 'subject' |
217 |
248 |
218 class delete_permission(RelationType): |
249 class delete_permission_rqlexpr(RelationDefinition): |
219 """grant permission to delete entity or relation through a group or rql |
250 """rql expression allowing to delete entities/relations of this type""" |
220 expression |
251 __permissions__ = META_RTYPE_PERMS |
221 """ |
252 name = 'delete_permission' |
222 __permissions__ = META_RTYPE_PERMS |
|
223 subject = ('CWEType', 'CWRelation') |
253 subject = ('CWEType', 'CWRelation') |
224 object = ('CWGroup', 'RQLExpression') |
254 object = 'RQLExpression' |
225 cardinality = '*?' |
255 cardinality = '*?' |
226 composite = 'subject' |
256 composite = 'subject' |
227 |
257 |
228 class update_permission(RelationType): |
258 class update_permission_rqlexpr(RelationDefinition): |
229 """grant permission to update entity or attribute through a group or rql |
259 """rql expression allowing to update entities/relations of this type""" |
230 expression |
260 __permissions__ = META_RTYPE_PERMS |
231 """ |
261 name = 'update_permission' |
232 __permissions__ = META_RTYPE_PERMS |
|
233 subject = ('CWEType', 'CWAttribute') |
262 subject = ('CWEType', 'CWAttribute') |
234 object = ('CWGroup', 'RQLExpression') |
263 object = 'RQLExpression' |
235 cardinality = '*?' |
264 cardinality = '*?' |
236 composite = 'subject' |
265 composite = 'subject' |
237 |
266 |
238 |
267 |
239 class is_(RelationType): |
268 class is_(RelationType): |