Index: WAeUP_SRP/trunk/profiles/default/layouts/student_clearance.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/layouts/student_clearance.xml	(revision 856)
+++ WAeUP_SRP/trunk/profiles/default/layouts/student_clearance.xml	(revision 858)
@@ -854,7 +854,4 @@
    <cell name="def_adm"/>
   </row>
-  <row>
-   <cell name="acknow"/>
-  </row>
  </table>
 </object>
Index: WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml	(revision 856)
+++ WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml	(revision 858)
@@ -38,4 +38,7 @@
                   acquired="True">
   </permission-map>
+  <permission-map name="View" acquired="True">
+   <permission-role>Owner</permission-role>
+  </permission-map>
  </state>
  <state state_id="clearance_requested" title="">
@@ -45,10 +48,29 @@
                   acquired="True">
   </permission-map>
+  <permission-map name="View" acquired="True">
+   <permission-role>Owner</permission-role>
+  </permission-map>
  </state>
  <state state_id="cleared_and_validated" title="">
   <exit-transition transition_id="create_content"/>
-  <permission-map name="View" acquired="True">
-   <permission-role>Owner</permission-role>
-  </permission-map>
+  <exit-transition transition_id="enter_clearance_pin"/>
+  <exit-transition transition_id="request_clearance"/>
+  <permission-map name="View" acquired="True">
+   <permission-role>Owner</permission-role>
+  </permission-map>
+ </state>
+ <state state_id="clearence_requested" title="">
+  <exit-transition transition_id="clear_and_validate"/>
+  <exit-transition transition_id="enter_clearance_pin"/>
+  <exit-transition transition_id="reject_clearance"/>
+  <permission-map name="Modify portal content"
+                  acquired="True">
+   <permission-role>SectionManager</permission-role>
+  </permission-map>
+  <permission-map name="View" acquired="True">
+  </permission-map>
+ </state>
+ <state state_id="closed" title="">
+  <exit-transition transition_id="open"/>
  </state>
  <state state_id="deferred" title="">
@@ -61,4 +83,13 @@
   <permission-map name="View" acquired="True">
    <permission-role>Owner</permission-role>
+  </permission-map>
+ </state>
+ <state state_id="opened" title="">
+  <exit-transition transition_id="close"/>
+  <permission-map name="Modify portal content"
+                  acquired="True">
+   <permission-role>Owner</permission-role>
+  </permission-map>
+  <permission-map name="View" acquired="True">
   </permission-map>
  </state>
@@ -118,4 +149,13 @@
   </guard>
  </transition>
+ <transition transition_id="close" title=""
+             new_state="closed" trigger="USER"
+             before_script="" after_script="">
+  
+  <guard>
+   <guard-role>Manager</guard-role>
+   <guard-role>SectionManager</guard-role>
+  </guard>
+ </transition>
  <transition transition_id="create" title=""
              new_state="student_created" trigger="USER"
@@ -176,4 +216,13 @@
    <guard-role>SectionManager</guard-role>
    <guard-role>ClearanceOfficer</guard-role>
+  </guard>
+ </transition>
+ <transition transition_id="open" title=""
+             new_state="opened" trigger="USER"
+             before_script="" after_script="">
+  
+  <guard>
+   <guard-role>Manager</guard-role>
+   <guard-role>SectionManager</guard-role>
   </guard>
  </transition>
Index: WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_form_manager.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_form_manager.pt	(revision 856)
+++ WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_form_manager.pt	(revision 858)
@@ -7,33 +7,31 @@
                                                layout_mode='edit',
                                                use_session=True);
-           form_action string:clearance_edit;
+           form_action string:clearance_edit_manager;
+           isManager context/isManager;
            edition python:True;
            creation python:False;
-           metadata nothing;
-           is_manager context/isManager;
+           review_state info/review_state
     ">
 <metal:block use-macro="here/waeup_content_master/macros/master">
-
   <metal:block fill-slot="header">
-    <span tal:condition="not: is_manager">
-        <metal:block use-macro="here/error_not_found/macros/not_found" />
+    <span tal:condition="not: isManager">
+      <metal:block use-macro="here/error_not_found/macros/not_found" />
     </span>
-    <span tal:condition="is_manager">
-    <a href=""
-       tal:attributes="href string:${here/academicsParent}">
-      <img tal:attributes="src string:${here/portal_url}/arrow_up.gif"/>
-      Up one level
-    </a>
-       <h3> 
-         <span tal:condition="info">
-           <span tal:content="info/student/Title" />:
-         </span>
-         <span tal:content="here/title_or_id" />
+    <span tal:condition="isManager">
+      <a href=""
+         tal:attributes="href string:${here/academicsParent}">
+        <img tal:attributes="src string:${here/portal_url}/arrow_up.gif"/>
+        Up one level
+      </a>
+      <h3> 
+        <span tal:condition="info">
+          <span tal:content="info/student/Title" />:
+        </span>
+        <span tal:content="here/title_or_id" />
       </h3>
-    <br />    
+      <br />    
     </span>
   </metal:block>
-
-  <metal:block fill-slot="main" tal:condition="is_manager">
+  <metal:block fill-slot="main">
     <form action="ACTION" method="post" id="editForm"
           enctype="multipart/form-data" class="workflow"
@@ -49,19 +47,34 @@
         </div>
       </div>
-    <input type="submit" class="standalone" name="cpsdocument_edit_button"
-         value="Save & Return later" 
-         id="cpsdocument_edit_button"
-         tal:condition="not:creation" />
-    <input type="submit" class="standalone"
-          tal:condition="request/final_submit|nothing"
-          name="final_submit"
-          tal:attributes="value request/final_submit"
-          />
-    </form>
-    <div id="ajax_psm" style="display:none">
-      ajax feedback
-    </div>
+      <input type="submit" class="standalone" 
+             name="cpsdocument_edit_button"
+             value="Save & Return later" 
+             id="cpsdocument_edit_button"
+             tal:condition="python: review_state == 'clearance_pin_entered'" />
+      <input type="submit" class="standalone"
+             name="cpsdocument_edit_and_view_button"
+             value="Save & Submit" 
+             id="cpsdocument_edit_and_view_button"
+             tal:condition="python: review_state == 'clearance_pin_entered'" />
+      <input type="submit" class="standalone" 
+             name="clear_and_validate_button"
+             value="Clear & Validate" 
+             id="clear_and_validate_button"
+             tal:condition="python:review_state == 'clearance_requested'" />
+      <input type="submit" class="standalone"
+             name="reject_clearance_button"
+             value="Reject Clearance" 
+             id="reject_clearance_button"
+             tal:condition="python:review_state == 'clearance_requested'" />
+      <input type="submit" class="standalone"
+             name="undo_clear_button"
+             value="Undo Clear & Validate" 
+             id="undo_clear_button"
+             tal:condition="python:review_state == 'cleared_and_validated'" />
+      </form>
+      <div id="ajax_psm" style="display:none">
+        ajax feedback
+      </div>
+    </metal:block>
   </metal:block>
-  
-</metal:block>
 </tal:block>
Index: WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_manager.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_manager.py	(revision 856)
+++ WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_manager.py	(revision 858)
@@ -5,7 +5,7 @@
 ##bind script=script
 ##bind subpath=traverse_subpath
-##parameters=REQUEST,proceed=None, cpsdocument_edit_button=None, final_submit=None, action=None
+##parameters=REQUEST
 ##title=
-# $Id: clearance_edit.py 832 2006-11-10 16:52:23Z joachim $
+# $Id: clearance_edit.py 852 2006-11-12 21:21:07Z henrik $
 """
 """
@@ -16,10 +16,13 @@
 current = DateTime.DateTime()
 
+cpsdocument_edit_button = REQUEST.has_key('cpsdocument_edit_button')
+cpsdocument_edit_and_view_button = REQUEST.has_key('cpsdocument_edit_and_view_button')
+clear_and_validate_button = REQUEST.has_key('clear_and_validate_button')
+undo_clear_button = REQUEST.has_key('undo_clear_button')
+reject_clearance_button = REQUEST.has_key('reject_clearance_button')
+
 # Until ajax posts directly to its own script...
 ##if 'ajax_edit' in REQUEST.form:
 ##    return context.cpsdocument_edit_ajax(REQUEST, cluster=cluster)
-
-# Check flexible controls
-#context.editLayouts(REQUEST=REQUEST)
 
 # Validate the document and write it if it's valid
@@ -33,9 +36,5 @@
 clear = info['clear']
 clear_doc = info['clear_doc']
-state = context.getStudentInfo()['review_state']
-if final_submit:
-    wftool.doActionFor(info['clear'],'close')
-    wftool.doActionFor(info['student'],'request_clearance')
-    return REQUEST.RESPONSE.redirect("%s/student_index" % info['url'])
+review_state = info['review_state']
 
 is_valid, ds = clear_doc.validate(request=REQUEST,
@@ -48,13 +47,22 @@
 args = {}
 action = "/clearance_edit_form_manager"
-if cpsdocument_edit_button:
-    if is_valid:
+if is_valid:
+    if cpsdocument_edit_button:
         psm = 'Content changed.'
-        if ds.get('acknow'):
-            args['final_submit'] = "Finally Submit"
-    else:
-        args = getFormUidUrlArg(REQUEST)
-        psm = "Please correct your errors."
-	args['portal_status_message'] = psm
+    elif cpsdocument_edit_and_view_button:
+        wftool.doActionFor(info['clear'],'close')
+        wftool.doActionFor(info['student'],'request_clearance')
+    elif clear_and_validate_button:
+        wftool.doActionFor(info['student'],'clear_and_validate')
+    elif reject_clearance_button:
+        wftool.doActionFor(info['clear'],'open')
+        wftool.doActionFor(info['student'],'enter_clearance_pin')
+    elif undo_clear_button:
+        wftool.doActionFor(info['student'],'request_clearance')
+else:
+    psm = "Please correct your errors."
+args = getFormUidUrlArg(REQUEST)
+args['review_state'] = review_state
+args['portal_status_message'] = psm
 if args:
   url = clear.absolute_url() + action + '?' + urlencode(args)
@@ -62,3 +70,2 @@
   url = clear.absolute_url() + action
 REQUEST.RESPONSE.redirect(url)
-
