Index: WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml	(revision 867)
+++ WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml	(revision 868)
@@ -101,6 +101,5 @@
   
   <guard>
-   <guard-role>Manager</guard-role>
-   <guard-role>SectionManager</guard-role>
+   <guard-expression>python: context.student_wf_guard(transition,state_change)</guard-expression>
   </guard>
  </transition>
@@ -110,7 +109,5 @@
   
   <guard>
-   <guard-role>Manager</guard-role>
-   <guard-role>SectionManager</guard-role>
-   <guard-role>Owner</guard-role>
+   <guard-expression>python: context.student_wf_guard(transition,state_change)</guard-expression>
   </guard>
  </transition>
@@ -120,7 +117,5 @@
   
   <guard>
-   <guard-role>Manager</guard-role>
-   <guard-role>SectionManager</guard-role>
-   <guard-role>ClearanceOfficer</guard-role>
+   <guard-expression>python: context.student_wf_guard(transition,state_change)</guard-expression>
   </guard>
  </transition>
@@ -139,7 +134,5 @@
   
   <guard>
-   <guard-role>Manager</guard-role>
-   <guard-role>SectionManager</guard-role>
-   <guard-role>Owner</guard-role>
+   <guard-expression>python: context.student_wf_guard(transition,state_change)</guard-expression>
   </guard>
   <transition-behavior behavior_id="allow-sub-create"/>
@@ -150,6 +143,5 @@
   
   <guard>
-   <guard-role>Manager</guard-role>
-   <guard-role>SectionManager</guard-role>
+   <guard-expression>python: context.student_wf_guard(transition,state_change)</guard-expression>
   </guard>
  </transition>
@@ -159,7 +151,5 @@
   
   <guard>
-   <guard-role>Manager</guard-role>
-   <guard-role>SectionManager</guard-role>
-   <guard-role>Owner</guard-role>
+   <guard-expression>python: context.student_wf_guard(transition,state_change)</guard-expression>
   </guard>
  </transition>
@@ -169,7 +159,5 @@
   
   <guard>
-   <guard-role>Manager</guard-role>
-   <guard-role>SectionManager</guard-role>
-   <guard-role>Owner</guard-role>
+   <guard-expression>python: context.student_wf_guard(transition,state_change)</guard-expression>
   </guard>
  </transition>
@@ -179,7 +167,5 @@
   
   <guard>
-   <guard-role>Manager</guard-role>
-   <guard-role>SectionManager</guard-role>
-   <guard-role>ClearanceOfficer</guard-role>
+   <guard-expression>python: context.student_wf_guard(transition,state_change)</guard-expression>
   </guard>
  </transition>
@@ -189,6 +175,5 @@
   
   <guard>
-   <guard-role>Manager</guard-role>
-   <guard-role>SectionManager</guard-role>
+   <guard-expression>python: context.student_wf_guard(transition,state_change)</guard-expression>
   </guard>
  </transition>
@@ -198,6 +183,5 @@
   
   <guard>
-   <guard-role>Manager</guard-role>
-   <guard-role>SectionManager</guard-role>
+   <guard-expression>python: context.student_wf_guard(transition,state_change)</guard-expression>
   </guard>
  </transition>
@@ -207,7 +191,5 @@
   
   <guard>
-   <guard-role>Manager</guard-role>
-   <guard-role>SectionManager</guard-role>
-   <guard-role>Owner</guard-role>
+   <guard-expression>python: context.student_wf_guard(transition,state_change)</guard-expression>
   </guard>
  </transition>
@@ -217,6 +199,5 @@
   
   <guard>
-   <guard-role>Manager</guard-role>
-   <guard-role>SectionManager</guard-role>
+   <guard-expression>python: context.student_wf_guard(transition,state_change)</guard-expression>
   </guard>
  </transition>
@@ -226,7 +207,5 @@
   
   <guard>
-   <guard-role>Manager</guard-role>
-   <guard-role>SectionManager</guard-role>
-   <guard-role>ClearanceOfficer</guard-role>
+   <guard-expression>python: context.student_wf_guard(transition,state_change)</guard-expression>
   </guard>
  </transition>
@@ -236,7 +215,5 @@
   
   <guard>
-   <guard-role>Manager</guard-role>
-   <guard-role>SectionManager</guard-role>
-   <guard-role>Owner</guard-role>
+   <guard-expression>python: context.student_wf_guard(transition,state_change)</guard-expression>
   </guard>
  </transition>
Index: WAeUP_SRP/trunk/skins/waeup_student/student_wf_guard.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/student_wf_guard.py	(revision 868)
+++ WAeUP_SRP/trunk/skins/waeup_student/student_wf_guard.py	(revision 868)
@@ -0,0 +1,53 @@
+## Script (Python) "student_wf_guard"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=REQUEST, transition, state_change
+##title=
+##
+# $Id$
+"""
+check if the current action is allowed by workflow
+"""
+request = REQUEST
+wftool = context.portal_workflow
+mtool = context.portal_membership
+member = mtool.getAuthenticatedMember()
+roles = member.getRolesInContext(context)
+def intersection(a,b):
+    r = []
+    for i in a:
+        if i in b:
+            r.append(i)
+    return r
+
+if transition in ('admit',):
+    if intersection(('Manager', 'SectionManager'),roles):
+        return True
+    return False
+if transition in ('apply_for_admission',
+                  'create_content',
+                  'enter_application_pin',
+                  'enter_clearance_pin',
+                  'pume_fail',
+                  'pume_pass'
+                  'request_clearance',
+                  ):
+    if intersection(('Manager', 'SectionManager','Owner'),roles):
+        return True
+    return False
+#
+#
+if transition in ('clear_and_validate',
+                  'defer',
+                  'finally_reject',
+                  'raise_objection',
+                  'reject_admission',
+                  'reject_clearance',
+                  ):
+    if intersection(('Manager', 'SectionManager'),roles)\
+       and context.isClearanceOfficer():
+        return True
+    return False
