Index: /WAeUP_SRP/trunk/profiles/default/actions.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/actions.xml	(revision 884)
+++ /WAeUP_SRP/trunk/profiles/default/actions.xml	(revision 885)
@@ -119,5 +119,5 @@
   </action>
   <action title="Students" action_id="view_students" category="navigation"
-     condition_expr="here/isStaff" url_expr="string:${portal_url}/campus/students"
+     condition_expr="python:here.isStaff() or here.isManager()" url_expr="string:${portal_url}/campus/students"
      visible="True">
    <permission>View</permission>
Index: /WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_subobject_wf/definition.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_subobject_wf/definition.xml	(revision 884)
+++ /WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_subobject_wf/definition.xml	(revision 885)
@@ -8,5 +8,9 @@
  <permission>View</permission>
  <state state_id="closed" title="">
-  <exit-transition transition_id="open"/>
+  <permission-map name="Modify portal content"
+                  acquired="True">
+   <permission-role>ClearanceOfficer</permission-role>
+  </permission-map>
+ <exit-transition transition_id="open"/>
  </state>
  <state state_id="content_addable" title="">
Index: /WAeUP_SRP/trunk/skins/waeup_default/isClearanceOfficer.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_default/isClearanceOfficer.py	(revision 885)
+++ /WAeUP_SRP/trunk/skins/waeup_default/isClearanceOfficer.py	(revision 885)
@@ -0,0 +1,15 @@
+## Script (Python) "isClearanceOfficer"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id$
+
+mtool = context.portal_membership
+roles = mtool.getAuthenticatedMember().getRolesInContext(context)
+return "ClearanceOfficer" in roles
+
Index: /WAeUP_SRP/trunk/skins/waeup_default/isManager.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_default/isManager.py	(revision 884)
+++ /WAeUP_SRP/trunk/skins/waeup_default/isManager.py	(revision 885)
@@ -9,8 +9,6 @@
 ##
 # $Id$
-"""
-return True if the member is considered a Manager,
-consider all non-Student members to be Managers
 
-"""
-return context.isStaff()
+mtool = context.portal_membership
+roles = mtool.getAuthenticatedMember().getRolesInContext(context)
+return "Manager" in roles
Index: /WAeUP_SRP/trunk/skins/waeup_default/isStaff.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_default/isStaff.py	(revision 884)
+++ /WAeUP_SRP/trunk/skins/waeup_default/isStaff.py	(revision 885)
@@ -9,11 +9,10 @@
 ##
 # $Id: $
-"""
 
-"""
 mtool = context.portal_membership
-if mtool.isAnonymousUser():
-    return False
-roles = mtool.getAuthenticatedMember().getRolesInContext(context)
-return not "Student" in roles
+member = mtool.getAuthenticatedMember()
+roles = member.getRolesInContext(context)
 
+return "SectionManager" in roles or\
+       "ClearanceOfficer" in roles or\
+       "ClearanceOfficers" in member.getGroups()
Index: /WAeUP_SRP/trunk/skins/waeup_default/isStudent.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_default/isStudent.py	(revision 884)
+++ /WAeUP_SRP/trunk/skins/waeup_default/isStudent.py	(revision 885)
@@ -9,7 +9,6 @@
 ##
 # $Id$
-"""
-return True if the member is considered a Student
-"""
-roles = context.portal_membership.getAuthenticatedMember().getRolesInContext(context)
+
+mtool = context.portal_membership
+roles = mtool.getAuthenticatedMember().getRolesInContext(context)
 return  "Student" in roles
Index: /WAeUP_SRP/trunk/skins/waeup_student/clearance_edit.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/clearance_edit.py	(revision 884)
+++ /WAeUP_SRP/trunk/skins/waeup_student/clearance_edit.py	(revision 885)
@@ -5,5 +5,5 @@
 ##bind script=script
 ##bind subpath=traverse_subpath
-##parameters=REQUEST, cpsdocument_edit_button=None, cpsdocument_edit_and_view_button=None, acknowledge=None
+##parameters=REQUEST
 ##title=
 # $Id$
@@ -16,10 +16,11 @@
 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')
+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 +34,9 @@
 clear = info['clear']
 clear_doc = info['clear_doc']
-state = context.getStudentInfo()['review_state']
+review_state = info['review_state']
 
 is_valid, ds = clear_doc.validate(request=REQUEST,
                                 schema_id = 'student_clearance',
-                                layout_id = 'student_clearance_fe',
+                                layout_id = 'student_clearance',
                                 proxy=clear,
                                 use_session=True)
@@ -48,12 +49,15 @@
         psm = 'Content changed.'
     elif cpsdocument_edit_and_view_button:
-        if acknowledge:
-            wftool.doActionFor(info['clear'],'close')
-            wftool.doActionFor(info['student'],'request_clearance')
-            return REQUEST.RESPONSE.redirect("%s/clearance_view" % info['url'])
-        psm = "You must tick the Acknowledgement Check Box before submission!"
+        wftool.doActionFor(info['clear'],'close')
+        wftool.doActionFor(info['student'],'request_clearance',dest_container=1)
+    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'],'reject_clearance')
 else:
     psm = "Please correct your errors."
 args = getFormUidUrlArg(REQUEST)
+args['review_state'] = review_state
 args['portal_status_message'] = psm
 if args:
Index: /WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_form.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_form.pt	(revision 884)
+++ /WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_form.pt	(revision 885)
@@ -1,28 +1,23 @@
 <tal:block define="
            info context/getStudentInfo;
+           isManager context/isManager;
+           isStaff context/isStaff;
+           isClearanceOfficer context/isClearanceOfficer;
+           isOwner context/isThisStudent;
+           review_state info/review_state;
+           edition python: (isOwner and review_state == 'clearance_pin_entered' or isManager) and not isClearanceOfficer;
+           mode python: test(edition,'edit','view');
            rendered_main python:info['clear_doc'].render(request=request,
-                                               layout_mode = 'edit',
+                                               layout_mode = mode,
                                                schema_id='student_clearance',
-                                               layout_id='student_clearance_fe',
-                                               layout_mode='edit',
+                                               layout_id='student_clearance',
                                                use_session=True);
            form_action string:clearance_edit;
-           edition python:True;
            creation python:False;
-           metadata nothing;
     ">
-<metal:block define-macro="edit_form">
 <metal:block use-macro="here/waeup_content_master/macros/master">
-
   <metal:block fill-slot="header">
-     <a href=""
-       tal:attributes="href string:${here/academicsParent}">
-      <img tal:attributes="src string:${here/portal_url}/arrow_up.gif"/>
-      Up one level
-    </a>
-    <h3>Fill Your Clearance/Eligibility Form!</h3>
-    <br />    
+    <metal:block use-macro="here/clearance_edit_lib/macros/header" />
   </metal:block>
-
   <metal:block fill-slot="main">
     <form action="ACTION" method="post" id="editForm"
@@ -39,31 +34,5 @@
         </div>
       </div>
-
-      <div>
-
-          <input type="checkbox" value="True" name="acknowledge" />     &nbsp;&nbsp;  
-
-          I hereby acknowledge by ticking this check box 
-          that, if it is discovered at any time that I do not possess any of the 
-          qualifications which I claim to have obtained, I will be expelled from the 
-          University and shall not be re-admitted for the same or any other programme, 
-          even if I have upgraded my previous qualifications or possess additional 
-          qualifications.    
-                        
-
-      </div>
-
-      <br />
-      
-      <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"
-             name="cpsdocument_edit_and_view_button"
-             value="Save & Submit" 
-             id="cpsdocument_edit_and_view_button"
-             tal:condition="not:creation" />
+      <metal:block use-macro="here/clearance_edit_lib/macros/buttons" />
       </form>
       <div id="ajax_psm" style="display:none">
@@ -72,4 +41,3 @@
     </metal:block>
   </metal:block>
-</metal:block>
 </tal:block>
Index: /WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_form_manager.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_form_manager.pt	(revision 884)
+++ /WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_form_manager.pt	(revision 885)
@@ -1,5 +1,10 @@
 <tal:block define="
            info context/getStudentInfo;
-           mode python: test(context.isClearanceOfficer(info),'view','edit');
+           isManager context/isManager;
+           isStaff context/isStaff;
+           isClearanceOfficer context/isClearanceOfficer;
+           isOwner context/isThisStudent;
+           edition python:(isOwner or isManager) and not isClearanceOfficer;
+           mode python: test(edition,'edit','view');
            rendered_main python:info['clear_doc'].render(request=request,
                                                layout_mode = mode,
@@ -8,6 +13,4 @@
                                                use_session=True);
            form_action string:clearance_edit_manager;
-           isManager context/isManager;
-           edition python:True;
            creation python:False;
            review_state info/review_state
@@ -15,8 +18,8 @@
 <metal:block use-macro="here/waeup_content_master/macros/master">
   <metal:block fill-slot="header">
-    <span tal:condition="not: isManager">
+    <span tal:condition="python: not(isStaff or isManager)">
       <metal:block use-macro="here/error_not_found/macros/not_found" />
     </span>
-    <span tal:condition="isManager">
+    <span tal:condition="python: isStaff or isManager">
       <a href=""
          tal:attributes="href string:${here/academicsParent}">
@@ -47,24 +50,5 @@
         </div>
       </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="Validate & Clear" 
-             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 == 'cleared_and_validated'" />
+      <metal:block use-macro="here/clearance_edit_lib/macros/buttons" />
       </form>
       <div id="ajax_psm" style="display:none">
Index: /WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_lib.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_lib.pt	(revision 885)
+++ /WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_lib.pt	(revision 885)
@@ -0,0 +1,85 @@
+<!--  clearance_edit_lib -->
+<!-- $Id$ -->
+<!--  header -->
+<metal:block define-macro="header">
+  <!--  Administration -->
+  <tal:block condition="python: not(isStaff or isManager or isOwner)">
+    <metal:block use-macro="here/error_not_found/macros/not_found" />
+  </tal:block>
+  <tal:block condition="python: isStaff or 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 />    
+  </tal:block>
+  <!--  Student -->
+  <tal:block condition="python: isOwner">
+    <a href=""
+       tal:attributes="href string:${here/academicsParent}">
+      <img tal:attributes="src string:${here/portal_url}/arrow_up.gif"/>
+      Up one level
+    </a>
+    <h3>Fill Your Clearance/Eligibility Form!</h3>
+    <br />    
+  </tal:block>
+</metal:block>
+<!--  buttons -->
+<metal:block define-macro="buttons">
+  <!--  isManager -->
+  <tal:block condition="context/isManager"> 
+    <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="Validate & Clear" 
+           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 == 'cleared_and_validated'" />
+  </tal:block>
+  <!--  isClearanceOfficer -->
+  <tal:block condition="context/isClearanceOfficer"> 
+    <input type="submit" class="standalone" 
+           name="clear_and_validate_button"
+           value="Validate & Clear" 
+           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 == 'cleared_and_validated'" />
+  </tal:block>
+  <!--  isStudent -->
+  <tal:block condition="context/isStudent"> 
+    <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'" />
+  </tal:block>
+</metal:block>
Index: /WAeUP_SRP/trunk/skins/waeup_student/co_searchStudents.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/co_searchStudents.py	(revision 884)
+++ /WAeUP_SRP/trunk/skins/waeup_student/co_searchStudents.py	(revision 885)
@@ -49,5 +49,5 @@
 pr = context.portal_registration
 path_info = request.get('PATH_INFO').split('/')
-is_manager = context.isManager
+is_manager = context.isManager()
 validate = request.has_key("cpsdocument_edit_button")
 default = {'search_mode': 'name',
@@ -69,5 +69,5 @@
                              #psm = "%s, %s" % (psm,ds),
                              students = items,
-                             is_manager = is_manager,
+                             allowed = True,
                              )
 what = ds.get('search_mode')
@@ -92,5 +92,5 @@
                              #psm = "%s, %s" % (psm,ds),
                              students = items,
-                             is_manager = is_manager,
+                             allowed = True,
                              )
 items = []
@@ -165,5 +165,5 @@
             info = context.getStudentInfo(item)
             students.append(info)
-    return context.students_co_view(rendered = rend,
+    return context.students_manager_view(rendered = rend,
                              psm = "",
                              #psm = "%d,%d matching Students found QS = %s" %\
@@ -171,10 +171,10 @@
                              #psm = "%d found QS = %s items: %s" % (len(items),query_step,items),
                              students = students,
-                             is_manager = is_manager,
+                             allowed = True,
                              )
-return context.students_co_view(rendered = rend,
+return context.students_manager_view(rendered = rend,
                              psm = """Step: %s found: %s Your search for "%s" in %s with state %s failed.<br\>%s""" % (query_step,len(items),st,what,state,bools),
                              students = students,
-                             is_manager = is_manager,
+                             allowed = True,
                              )
 
Index: /WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py	(revision 884)
+++ /WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py	(revision 885)
@@ -27,5 +27,5 @@
     if mtool.isAnonymousUser():
         return None
-    elif context.isManager() and 'students' in path_info:
+    elif not context.isStudent() and 'students' in path_info:
         student_id = path_info[path_info.index('students')+1]
     else:
Index: eUP_SRP/trunk/skins/waeup_student/isClearanceOfficer.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/isClearanceOfficer.py	(revision 884)
+++ 	(revision )
@@ -1,32 +1,0 @@
-## Script (Python) "isClearanceOfficer"
-##bind container=container
-##bind context=context
-##bind namespace=
-##bind script=script
-##bind subpath=traverse_subpath
-##parameters=info=None
-##title=
-##
-# $Id$
-"""
-
-"""
-wftool = context.portal_workflow
-mtool = context.portal_membership
-member = mtool.getAuthenticatedMember()
-
-if info is None:
-    info = context.getStudentInfo()
-if info is None:
-    return False
-if info['course'] is None:
-    return False
-
-res = context.portal_catalog(portal_type="Department",id=info['course_doc'].department)
-if len(res) != 1:
-    return False
-
-roles = member.getRolesInContext(res[0].getObject())
-
-return "ClearanceOfficer" in roles
-
Index: /WAeUP_SRP/trunk/skins/waeup_student/searchStudents.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/searchStudents.py	(revision 884)
+++ /WAeUP_SRP/trunk/skins/waeup_student/searchStudents.py	(revision 885)
@@ -64,5 +64,5 @@
                              #psm = "%s, %s" % (psm,ds),
                              students = items,
-                             is_manager = is_manager,
+                             allowed = True,
                              )
 what = ds.get('search_mode')
@@ -87,5 +87,5 @@
                              #psm = "%s, %s" % (psm,ds),
                              students = items,
-                             is_manager = is_manager,
+                             allowed = True,
                              )
 items = []
@@ -162,9 +162,9 @@
                              #psm = "%d found QS = %s items: %s" % (len(items),query_step,items),
                              students = students,
-                             is_manager = is_manager,
+                             allowed = True,
                              )
 return context.students_manager_view(rendered = rend,
                              psm = """Step: %s found: %s Your search for "%s" in %s with state %s failed.<br\>%s""" % (query_step,len(items),st,what,state,bools),
                              students = students,
-                             is_manager = is_manager,
+                             allowed = True,
                              )
Index: /WAeUP_SRP/trunk/skins/waeup_student/students_manager_view.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/students_manager_view.pt	(revision 884)
+++ /WAeUP_SRP/trunk/skins/waeup_student/students_manager_view.pt	(revision 885)
@@ -2,5 +2,5 @@
             portal_status_message options/psm;
             students options/students;
-            is_manager options/is_manager;"
+            allowed options/allowed|nothing"
             >
   <metal:body use-macro="here/main_template/macros/master">
@@ -13,8 +13,8 @@
     
     <metal:main fill-slot="main">
-      <span tal:condition="not: is_manager">
+      <span tal:condition="not: allowed">
         <metal:block use-macro="here/error_not_found/macros/not_found" />
       </span>
-      <span tal:condition="is_manager"
+      <span tal:condition="allowed"
         tal:define="items students;
         columns python:3;
