fix spent_for permissions, use class notation to define the relation
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 09 Feb 2010 13:42:59 +0100
changeset 28 1ee82b460998
parent 27 bd4d1dc13ff0
child 29 989f05cf876e
fix spent_for permissions, use class notation to define the relation
migration/0.4.0_Any.py
schema.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/migration/0.4.0_Any.py	Tue Feb 09 13:42:59 2010 +0100
@@ -0,0 +1,1 @@
+sync_schema_props_perms('spent_for')
--- a/schema.py	Tue Feb 09 13:13:30 2010 +0100
+++ b/schema.py	Tue Feb 09 13:42:59 2010 +0100
@@ -1,7 +1,13 @@
 # template's specific schema
-from yams.buildobjs import SubjectRelation
+from yams.buildobjs import RelationDefinition
+from cubicweb.schema import RRQLExpression
 
-from cubes.expense.schema import Expense
-
-Expense.add_relation(SubjectRelation('Workcase', cardinality='?*'),
-                     name='spent_for')
+class spent_for(RelationDefinition):
+    subject = 'Expense'
+    object = 'Workcase'
+    cardinality = '?*'
+    __permissions__ = {
+        'read' : ('managers', 'users'),
+        'add': ('managers', RRQLExpression('S in_state ST, NOT ST name "accepted"')),
+        'delete': ('managers', RRQLExpression('S in_state ST, NOT ST name "accepted"')),
+        }