# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1265719379 -3600
#      Tue Feb 09 13:42:59 2010 +0100
# Node ID 1ee82b460998ac393f5dbbe324fe12bad2f9bc37
# Parent  bd4d1dc13ff08c7c8939261beb9df24e3cbe9210
fix spent_for permissions, use class notation to define the relation

diff --git a/migration/0.4.0_Any.py b/migration/0.4.0_Any.py
new file mode 100644
--- /dev/null
+++ b/migration/0.4.0_Any.py
@@ -0,0 +1,1 @@
+sync_schema_props_perms('spent_for')
diff --git a/schema.py b/schema.py
--- a/schema.py
+++ b/schema.py
@@ -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"')),
+        }