Index: /WAeUP_SRP/trunk/skins/waeup_student/co_search.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/co_search.py	(revision 875)
+++ /WAeUP_SRP/trunk/skins/waeup_student/co_search.py	(revision 875)
@@ -0,0 +1,178 @@
+## Script (Python) "co_search"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=REQUEST
+##title=
+##
+# $Id: $
+"""
+list Students for ClearanceOfficers
+"""
+request = REQUEST
+wftool = context.portal_workflow
+mtool = context.portal_membership
+member = mtool.getAuthenticatedMember()
+roles = member.getRolesInContext(context)
+try:
+    from Products.AdvancedQuery import Eq, Between, Le,In
+    evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery
+except:
+    evalAdvancedQuery = None
+
+def cmp_id(a,b):
+    if a.getId() > b.getId():
+        return 1
+    return -1
+
+request = context.REQUEST
+form = request.form
+fget = form.get
+student_subobjects = ("StudentApplication",
+                      "StudentPersonal",
+                      "StudentStudyCourse",
+                      "StudentAccommodation",
+                      "StudentStudyLevel",)
+
+student_objects = student_subobjects + ("Student",)
+
+info = {}
+items = []
+wf = context.portal_workflow
+catalog = context.portal_catalog
+#student_wf_states = wf.waeup_student_wf.states.keys()
+#info['wf_states'] = student_wf_states
+#info['wf_states'][0] = " ----- "
+lt = context.portal_layouts
+pr = context.portal_registration
+path_info = request.get('PATH_INFO').split('/')
+is_manager = context.isManager
+validate = request.has_key("cpsdocument_edit_button")
+default = {'search_mode': 'name',
+        'review_state': 'clearance_requested',
+        'search_string': ''
+        }
+
+rend,psm,ds = lt.renderLayout(layout_id= 'student_search',
+                      schema_id= 'student_search',
+                      context=context,
+                      mapping=validate and request,
+                      ob=default,
+                      layout_mode='edit',
+                      formaction="co_search"
+                      )
+if psm == '':
+    return context.students_manager_view(rendered = rend,
+                             psm = psm,
+                             #psm = "%s, %s" % (psm,ds),
+                             students = items,
+                             is_manager = is_manager,
+                             )
+what = ds.get('search_mode')
+state = ds.get('review_state')
+st = term = ds.get('search_string')
+err = False
+with_review = state != "all"
+only_review = with_review and not term
+##with_level_results = state.startswith("category") or\
+##                     state in ('content_addable',) and\
+##                     evalAdvancedQuery is not None
+bools = "with_review = %s<br\> only_review = %s<br\>" % (with_review,only_review)
+if not term and not with_review:
+    psm = "You must specify a search string when searching 'all states'."
+    err = True
+elif '*' in term:
+    psm = "you cannot use the '*' alone"
+    err = True
+if err:
+    return context.students_manager_view(rendered = rend,
+                             psm = psm,
+                             #psm = "%s, %s" % (psm,ds),
+                             students = items,
+                             is_manager = is_manager,
+                             )
+items = []
+res = []
+portal_type_query = {'query':['Student','StudentApplication','StudentPersonal']}
+st_queries = ('jamb_reg_no','matric_no','name')
+query_step = 0
+review_res = None
+query = None
+if len(term) > 0:
+    if what == "student_id":
+        query_step = 1
+        query = Eq('portal_type','Student') & Eq('id', term.strip())
+    elif what in st_queries:
+        if what == "jamb_reg_no":
+            query_step = 2
+            pt = ('StudentApplication',)
+            st = "%s" % term.strip().lower()
+        elif what == "matric_no":
+            query_step = 3
+            pt = ('StudentClearance',)
+            st = "%s" % term.strip().lower()
+        elif what == "name":
+            query_step = 4
+            pt = ('StudentPersonal')
+            st = "%s" % term.strip()
+        query = In('portal_type',pt) & Eq('SearchableText',"%s*" % term.strip())
+    res = evalAdvancedQuery(query)
+if with_review:
+    query_step += 10
+    review_res = evalAdvancedQuery(In('portal_type',student_objects) & Eq('review_state',state))
+search_set = []
+if res:
+    for r in res:
+        if r.portal_type in ("StudentStudyLevel",):
+            student = r.getObject().aq_parent.aq_parent
+        elif r.portal_type in student_subobjects:
+            student = r.getObject().aq_parent
+        else:
+            student = r.getObject()
+        search_set.append(student)
+review_set = []
+if review_res:
+    for r in review_res:
+        if r.portal_type in ("StudentStudyLevel",):
+            student = r.getObject().aq_parent.aq_parent
+        elif r.portal_type in student_subobjects:
+            student = r.getObject().aq_parent
+        else:
+            student = r.getObject()
+        review_set.append(student)
+all = []
+if only_review:
+    all = review_set
+elif with_review:
+    for i in search_set:
+        if i in review_set:
+            all.append(i)
+else:
+    all = search_set
+for a in all:
+    if a in items:
+        continue
+    items.append(a)
+students = []
+items.sort(cmp_id)
+if items:
+    for item in items:
+        info = context.getStudentInfo(item)
+        if context.isClearanceOfficer(info):
+            students.append(info)
+    return context.co_search_form(rendered = rend,
+                             psm = "%d,%d matching Students found QS = %s" %\
+                                    (len(review_set),len(search_set),query_step),
+                             #psm = "%d found QS = %s items: %s" % (len(items),query_step,items),
+                             students = students,
+                             is_manager = is_manager,
+                             )
+return context.co_search_form(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,
+                             )
+
+
Index: /WAeUP_SRP/trunk/skins/waeup_student/co_search_form.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/co_search_form.pt	(revision 875)
+++ /WAeUP_SRP/trunk/skins/waeup_student/co_search_form.pt	(revision 875)
@@ -0,0 +1,113 @@
+<metal:html tal:define="rendered options/rendered;
+            portal_status_message options/psm;
+            students options/students;
+            is_manager options/is_manager;"
+            >
+  <metal:body use-macro="here/main_template/macros/master">
+    <metal:block fill-slot="header"
+                 tal:define="creation creation|nothing;
+                 edition edition|nothing;
+                 metadata metadata|nothing"
+                 >
+    </metal:block>
+    
+    <metal:main fill-slot="main">
+      <span tal:condition="not: is_manager">
+        <metal:block use-macro="here/error_not_found/macros/not_found" />
+      </span>
+      <span tal:condition="is_manager"
+        tal:define="items students;
+        columns python:3;
+        items_per_page python:40;
+        max_items python:300;
+        zoom python:0;
+        batches_all python:here.getBatchList(items,columns, items_per_page,zoom,max_items=400);
+        batches python:batches_all[0];
+        batch_info python:batches_all[1];
+        zoomed python:batches_all[2];
+        mq nocall:modules/ZTUtils/make_query;"
+        tal:omit-tag=""
+        >
+      
+        <h3> Clearance Officer Search</h3>
+        
+        <br />
+      
+        <span tal:replace="structure rendered" />
+        <tal:block tal:condition="python: batch_info and batch_info['nb_pages'] > 1">
+          <div class="batchLayout">
+            <span i18n:translate="">
+              Objects: 
+              <strong>
+                <tal:block replace="batch_info/start"
+                           i18n:name="batch_start" /> - <tal:block replace="batch_info/limit"
+                                                                   i18n:name="batch_limit" />
+              </strong>
+              of <tal:block replace="batch_info/length"
+                            i18n:name="batch_length" />
+            </span>
+          </div>
+          <br />
+        </tal:block>
+        <table class="contentListing" width="100%">
+          <span tal:repeat="rows batches" tal:omit-tag="">
+            <span tal:repeat="student rows">
+              <tr tal:condition="student" 
+                  tal:attributes="class python:test(repeat['student'].even(), 'even ajaxtd', 'odd ajaxtd')">
+                <td><a href="id" tal:attributes="href string:${student/student/absolute_url}"
+                       tal:content="student/id"></a></td>    
+                <td>
+                  <span tal:replace="python: student['per_doc'].firstname" />
+                  <span tal:replace="python: student['per_doc'].middlename" />
+                  <span tal:replace="python: student['per_doc'].lastname" />
+                </td>    
+                <td><span tal:replace="python: student['app_doc'].jamb_reg_no" /></td>    
+                <td><a href="id" 
+                       tal:attributes="href string:${student/student/clearance/absolute_url}"
+                       tal:content="student/review_state"></a></td>    
+                <td>
+              </tr>
+            </span>
+          </span>
+        </table>
+        <tal:block condition="python:batch_info and batch_info['nb_pages'] > 1">
+          <div class="pageNavigationLayout">
+            <a tal:define="previous batch_info/previous"
+               tal:condition="python:previous is not None"
+               tal:attributes="href python:'%s?%s'%(request['URL'],
+               mq(request.form, b_start=0))"
+               >
+            (&lt;&lt;)</a>
+            <a tal:define="previous batch_info/previous"
+               tal:condition="python:previous is not None"
+               tal:attributes="href python:'%s?%s'%(request['URL'],
+               mq(request.form, b_start=previous))"
+               i18n:translate="batch_previous">Previous</a>
+            <tal:block repeat="page batch_info/pages">
+              <tal:block condition="python:page != batch_info['start'] - 1">
+                <a tal:attributes="href python:'%s?%s'%(request['URL'],
+                mq(request.form, b_start=page))"
+                tal:content="repeat/page/number">1</a>&nbsp;
+              </tal:block>
+              <tal:block condition="python:page == batch_info['start'] - 1">
+                <span tal:content="string:${repeat/page/number}" />&nbsp;
+              </tal:block>
+            </tal:block>
+            <a tal:define="next batch_info/next"
+               tal:condition="python:next is not None"
+               tal:attributes="href python:'%s?%s'%(request['URL'],
+               mq(request.form, b_start=next))"
+               i18n:translate="batch_next">Next</a>
+            <a tal:define="next batch_info/next;
+            last_page python:batch_info['pages'][-1]"
+            tal:condition="python:next is not None"
+            tal:attributes="href python:'%s?%s'%(request['URL'],
+            mq(request.form, b_start=last_page))"
+            >
+            (&gt;&gt;)</a>
+          </div>
+        </tal:block>
+      </span>
+    </metal:main>
+  </metal:body>
+</metal:html>
Index: /WAeUP_SRP/trunk/skins/waeup_student/get_searchable_student_states.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/get_searchable_student_states.py	(revision 874)
+++ /WAeUP_SRP/trunk/skins/waeup_student/get_searchable_student_states.py	(revision 875)
@@ -18,7 +18,9 @@
 voc = context.portal_vocabularies.searchable_student_states
 
-if key is None:
-    return voc.items()
-return voc.get(key)
+if key is not None:
+    return voc.get(key)
+if "ClearanceOfficers" in member.getGroups():
+    return [item for item in voc.items() if item[0].startswith('clear')]
+return voc.items()
 
 
Index: /WAeUP_SRP/trunk/skins/waeup_student/isClearanceOfficer.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/isClearanceOfficer.py	(revision 874)
+++ /WAeUP_SRP/trunk/skins/waeup_student/isClearanceOfficer.py	(revision 875)
@@ -5,5 +5,5 @@
 ##bind script=script
 ##bind subpath=traverse_subpath
-##parameters=
+##parameters=info=None
 ##title=
 ##
@@ -16,5 +16,6 @@
 member = mtool.getAuthenticatedMember()
 
-info = context.getStudentInfo()
+if info is None:
+    info = context.getStudentInfo()
 if info is None:
     return False
@@ -28,4 +29,4 @@
 roles = member.getRolesInContext(res[0].getObject())
 
-return "ClearanceOfficer" in roles or context.isManager
+return "ClearanceOfficer" in roles
 
