Index: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/course_result_delete.py
===================================================================
--- WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/course_result_delete.py	(revision 1545)
+++ WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/course_result_delete.py	(revision 1558)
@@ -18,7 +18,13 @@
 ret_url = here.absolute_url()
 
+message = ''
 if ids:
-    here.manage_delObjects(ids)
-    message = 'portal_status_message=psm_item(s)_deleted'
+    real_ids = []
+    for id in ids:
+        if context.hasObject(id):
+            real_ids.append(id)
+    if real_ids:
+        context.manage_delObjects(real_ids)
+        message = 'portal_status_message=psm_item(s)_deleted'
 else:
     message = 'portal_status_message=psm_select_at_least_one_document'
Index: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/create_level.py
===================================================================
--- WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/create_level.py	(revision 1545)
+++ WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/create_level.py	(revision 1558)
@@ -41,4 +41,10 @@
 elif in_progress == 'started':
     return
+
+if context.hasObject(current_level):
+    return
+    level = getattr(context,current_level)
+    return response.redirect("%s" % level.absolute_url())
+    
 context.invokeFactory('StudentStudyLevel',"%s" % current_level)
 level = getattr(context,"%s" % current_level)
@@ -101,3 +107,2 @@
 session.set('in_progress','finished')
 return
-return response.redirect("%s" % level.absolute_url())
Index: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/getRetStudentStatistics.py
===================================================================
--- WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/getRetStudentStatistics.py	(revision 1545)
+++ WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/getRetStudentStatistics.py	(revision 1558)
@@ -13,5 +13,5 @@
 """
 import logging
-logger = logging.getLogger('Student.Statistics')
+logger = logging.getLogger('Skins.getRetStudentStatistics')
 
 try:
@@ -21,20 +21,26 @@
 except:
     evalAdvancedQuery = None
-logger.info('"%s","invoked returning statistics"' % context.portal_membership.getAuthenticatedMember())
+logger.info('%s invoked returning statistics' % context.portal_membership.getAuthenticatedMember())
 l = []
 if not context.isStaff():
     return l
 dep = {}
-sum = 0
 dep['id'] = "All Faculties"
 
-#from Products.zdb import set_trace;set_trace()
 
-ret_res = context.portal_catalog(review_state ='returning')
-ret_ids = [r.getId for r in ret_res]
-ret = len(ret_res)
-dep['total'] = ret
+ret_res1 = context.portal_catalog(review_state = 'returning')
+ret_ids1 = [r.getId for r in ret_res1]
+total_ret = len(ret_ids1)
+
+ret_res2 = context.portal_catalog(review_state = ('school_fee_paid','courses_registered','courses_validated',))
+ret_ids2 = [r.getId for r in ret_res2]
+
+retquery = Ge('level','300') | (Eq('level','200') & Eq('entry_mode','UME'))
+ret_res3 = aq_students(retquery)
+ret_ids3 = [r.id for r in ret_res3]
 
 l.append(dep)
+sum_ret = 0
+sum_sfp = 0
 fs = context.portal_catalog(portal_type="Faculty")
 for fid in [f.getId for f in fs]:
@@ -45,18 +51,20 @@
     stud_ids = [r.id for r in stud_res]
     total = float(len(stud_res))
-
     if total == 0:
         continue
-
-    ret = len([s for s in stud_ids if s in ret_ids])
-    dep['returned'] = ret
-    sum += ret
-
-    if ret == 0:
-        continue
-
+    sfp = len([s for s in stud_ids if s in ret_ids2 and s in ret_ids3])
+    dep['sfp'] = sfp
+    ret = len([s for s in stud_ids if s in ret_ids1])
+    dep['ret'] = ret
+    sum_ret += ret
+    sum_sfp += sfp
+       
     l.append(dep)
 
-l[0]['sum'] = sum
+l[0]['ret'] = sum_ret
+l[0]['sfp'] = sum_sfp
+l[0]['total_ret'] = total_ret + sum_sfp
+l[0]['total_li'] = sum_ret + sum_sfp
+
 
 return l
Index: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/get_searchable_student_states.py
===================================================================
--- WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/get_searchable_student_states.py	(revision 1545)
+++ WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/get_searchable_student_states.py	(revision 1558)
@@ -23,4 +23,7 @@
     return [item for item in voc.items() if item[0].startswith('clear') or
                                          item[0] in ("all",)]
+elif "CourseAdvisers" in member.getGroups():
+    return [item for item in voc.items() if item[0].startswith('courses') or
+                                         item[0] in ("all",)]
 return voc.items()
 
Index: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/search_students.py
===================================================================
--- WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/search_students.py	(revision 1545)
+++ WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/search_students.py	(revision 1558)
@@ -61,7 +61,9 @@
 user_info['faculties'] = []
 co_view = False
+ca_view = False
 faculties =  fget('faculties')
 departments = fget('departments')
-dep_str = fac_str = ''
+certificate_level = fget('certificate_level')
+dep_str = fac_str = certificate_level_str = ''
 if "ClearanceOfficers" in member.getGroups():
     state = "clearance_requested"
@@ -93,4 +95,21 @@
         user_info['departments'] = departments
         dep_str = " ".join(departments)
+elif "CourseAdvisers" in member.getGroups():
+    state = "courses_registered"
+    only_review = False
+    ca_view = True
+    if certificate_level:
+        #from Products.zdb import set_trace;set_trace()
+        certificate_level_str = certificate_level
+        certificate_level = certificate_level.split()
+    else:
+        query = In('portal_type',('StudyLevel',)) &\
+                 In('localUsersWithRoles', ("user:%s" % member,))
+        res = evalAdvancedQuery(query)
+        certificate_level = []
+        if res:
+            certificate_level = ['/'.join(f.getPath().split('/')[-2:]) for f in res]
+        user_info['certificate_level'] = certificate_level
+        certificate_level_str = " ".join(certificate_level)
 default = {'search_mode': 'student_id',
         'review_state': state,
@@ -106,4 +125,5 @@
                       faculties = fac_str,
                       departments = dep_str,
+                      certificate_level = certificate_level_str,
                       commit = False,
                       )
@@ -200,4 +220,22 @@
         end = DateTime().timeTime()
         logger.info('"%s","searchtime","%6.2f"' % (member,end-start))
+elif ca_view:
+    only_review = False
+    with_review = True
+    if with_timer:
+        start = DateTime().timeTime()
+        logger.info('"%s","start 200"' % member)
+    courses = [cl.split('/')[0] for cl in certificate_level]
+    levels = [cl.split('/')[1] for cl in certificate_level]
+    query = In('course',courses) & In('level',levels)
+    res = aq_students(query)
+    if with_timer:
+        end = DateTime().timeTime()
+        logger.info('"%s","searchtime","%6.2f"' % (member,end-start))
+        start = DateTime().timeTime()
+    search_set = [r.id for r in res]
+    if with_timer:
+        end = DateTime().timeTime()
+        logger.info('"%s","searchtime","%6.2f"' % (member,end-start))
 if with_timer:
     logger.info('"%s","start 300"' % member)
Index: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/search_students_form.pt
===================================================================
--- WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/search_students_form.pt	(revision 1545)
+++ WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/search_students_form.pt	(revision 1558)
@@ -35,6 +35,4 @@
       </span>
       </strong>
-     
-              
         <h3> Search Student Section</h3><br />
           You are logged in as member <span tal:replace="info/member|nothing" /> 
@@ -45,4 +43,8 @@
           <span tal:condition="info/departments|nothing" tal:omit-tag="">
             and <span tal:repeat="department info/departments|nothing" tal:content="department"/></span>.
+          <span tal:condition="info/certificate_level|nothing" tal:omit-tag="">
+            who is CourseAdviser for 
+            <span tal:repeat="cl info/certificate_level" tal:content="cl" />
+          </span>
           <br /><br />
         <span tal:replace="structure rendered" />
Index: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/statistics_ret_view.pt
===================================================================
--- WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/statistics_ret_view.pt	(revision 1545)
+++ WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/statistics_ret_view.pt	(revision 1558)
@@ -24,9 +24,15 @@
       <h3>Returning Student Statistics</h3>
       <br />      
+      <span tal:content="python:departments[0]['total_ret']" /> 
+      returning student records have been imported. 
+      <span tal:content="python:departments[0]['total_li']" /> returning students 
+      have logged in.
+      <br /><br />
       <span tal:condition="not:isAnon">
         <table>
           <tr class="odd ajaxtd">
             <th >Faculty</th>
-            <th align="right">Returning</th>
+            <th align="right">RET</th>
+            <th align="right">SFP</th>
           </tr>
           <tr tal:define="d python:departments[0]"
@@ -34,5 +40,8 @@
               <td width="80px">All Faculties</td>
               <td width="80px" align="right"> 
-                <span tal:content="d/sum" /> of <span tal:content="d/total" />
+                <span tal:content="d/ret" />
+              </td>   
+              <td width="80px" align="right"> 
+                <span tal:content="d/sfp" />
               </td>              
           </tr>
@@ -41,9 +50,16 @@
               <td width="80px"> <span tal:content="d/id" /> </td>
               <td width="80px" align="right"> 
-                <span tal:content="d/returned " />
-              </td>              
+                <span tal:content="d/ret" />
+              </td>       
+              <td width="80px" align="right"> 
+                <span tal:content="d/sfp" />
+              </td>                              
           </tr>
         </table>
         <br />
+        <table>
+        <tr><td>RET:</td> <td>Returning students who only logged in</td></tr>
+        <tr><td>SFP:</td> <td>Returning students who paid their school fee</td></tr>
+        </table>        
       </span>
       </span>
Index: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/students_index.py
===================================================================
--- WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/students_index.py	(revision 1545)
+++ WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/students_index.py	(revision 1558)
@@ -23,5 +23,6 @@
 students_url = "%s/campus/students" % (context.portal_url())
 
-if "ClearanceOfficers" in member.getGroups():
+if "ClearanceOfficers" in member.getGroups() or\
+   "CourseAdvisers" in member.getGroups():
     return redirect("%s/search_students" % context.portal_url())
 if context.isSectionOfficer():
Index: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/study_level_view.pt
===================================================================
--- WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/study_level_view.pt	(revision 1545)
+++ WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/study_level_view.pt	(revision 1558)
@@ -63,5 +63,9 @@
         <h4>Session Courses</h4>
         <br />
-        <table class="contentListing" width="100%" summary="content layout" id="folder_content">      
+      <div class="" tal:condition="not: info/normal">
+        Your faculty has not yet provided the list of courses for your certificate. Please contact your faculty!
+      </div>
+        <table class="contentListing" width="100%" id="folder_content"
+               tal:condition="info/normal">      
           <tr tal:repeat="row info/normal"
               tal:attributes="class python:test(repeat['row'].even(), 'even ajaxtd', 'odd ajaxtd')">
@@ -106,5 +110,6 @@
                        />
                 <br /><br />
-                <input type="submit" name="register_courses:method"
+                <input tal:condition="info/normal" 
+                       type="submit" name="register_courses:method"
                        class="context" value="Submit" />
             </td>
