Index: WAeUP_SRP/trunk/skins/waeup_student/application_edit.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/application_edit.py	(revision 1014)
+++ WAeUP_SRP/trunk/skins/waeup_student/application_edit.py	(revision 1016)
@@ -15,4 +15,6 @@
 import DateTime
 current = DateTime.DateTime()
+import logging
+logger = logging.getLogger('Student.Application.Edit')
 
 # Until ajax posts directly to its own script...
@@ -27,4 +29,8 @@
 info = context.getStudentInfo()
 
+if info is None:
+    logger.info('"anonymous access","%s"' % request.get('URL0'))
+    REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
+    
 student = info['student']
 app = info['app']
@@ -50,4 +56,5 @@
     elif cpsdocument_edit_and_view_button:
         if app_doc.passport is not None:
+            logger.info('"%s", "continue' % (info['id']))
             action = "/start_clearance"
             base_url = student.absolute_url()
Index: WAeUP_SRP/trunk/skins/waeup_student/clearance_edit.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/clearance_edit.py	(revision 1014)
+++ WAeUP_SRP/trunk/skins/waeup_student/clearance_edit.py	(revision 1016)
@@ -15,4 +15,6 @@
 import DateTime
 current = DateTime.DateTime()
+import logging
+logger = logging.getLogger('Student.Clearance')
 
 cpsdocument_edit_button = REQUEST.has_key('cpsdocument_edit_button')
@@ -35,4 +37,6 @@
 clear = info['clear']
 clear_doc = info['clear_doc']
+student_id = info['id']
+member_id = str(context.portal_membership.getAuthenticatedMember())
 
 is_valid, ds = clear_doc.validate(request=REQUEST,
@@ -51,5 +55,7 @@
            action = "/clearance_edit_form"        
     elif cpsdocument_edit_and_view_button:
-        if acknowledge:
+        if acknowledge and info['review_state'] == "clearance_pin_entered":
+            logger.info('"%s","requested clearance"' % (student_id))
+            info['clear_doc'].edit(mapping = {'request_date': current,})
             wftool.doActionFor(info['clear'],'close')
             wftool.doActionFor(info['student'],'request_clearance',dest_container=1)
@@ -57,12 +63,22 @@
             if context.isStudent():
                action = "/clearance_view"
+        elif acknowledge and info['review_state'] != "clearance_pin_entered":
+            logger.info('"%s","double requested clearance"' % (student_id))
+            psm = "You have already requested clearance"
+            if context.isStudent():
+               action = "/clearance_edit_form"
         else:
             psm = "You must tick the acknowledgement check box before submission!"
             if context.isStudent():
                action = "/clearance_edit_form"
-    elif clear_and_validate_button:
+    elif clear_and_validate_button and info['review_state'] == "clearance_requested":
+        logger.info('"%s","cleared","%s"' % (member_id,student_id ))
         wftool.doActionFor(info['student'],'clear_and_validate')
+        info['clear_doc'].edit(mapping = {'cleared_date': current,})
         psm = "Clearance and eligibility record is validated and and student is cleared!"
+    elif clear_and_validate_button and info['review_state'] == "cleared_and_validated":
+        psm = "This student is already cleared!"
     elif reject_clearance_button:
+        logger.info('"%s","rejected clearance for","%s"' % (member_id,student_id ))
         wftool.doActionFor(info['clear'],'open')
         wftool.doActionFor(info['student'],'reject_clearance')
Index: WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py	(revision 1014)
+++ WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py	(revision 1016)
@@ -34,8 +34,5 @@
         try:
             requested_id = path_info[path_info.index('students')+1]
-        except ValueError:
-            student_id = member_id
-            break
-        except IndexError:
+        except (ValueError,IndexError):
             student_id = member_id
             break
Index: WAeUP_SRP/trunk/skins/waeup_student/start_clearance.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/start_clearance.py	(revision 1014)
+++ WAeUP_SRP/trunk/skins/waeup_student/start_clearance.py	(revision 1016)
@@ -7,4 +7,6 @@
 current = DateTime.DateTime()
 pr = context.portal_registration
+import logging
+logger = logging.getLogger('Student.Clearance.Start')
 
 type_name = 'Student'
@@ -18,4 +20,8 @@
 pr = context.portal_registration
 
+info = context.getStudentInfo()
+app_doc = info['app_doc']
+review_state = info['review_state']
+
 res,psm,ds = lt.renderLayout(layout_id='student_clearance',
                       schema_id= 'student_clearance',
@@ -27,25 +33,5 @@
                       button = "Start",
                       )
-
-info = context.getStudentInfo()
-app_doc = info['app_doc']
-if app_doc.passport is None:
-    return context.clearance_pin_form(rendered = res,
-                                 psm = "You must upload your passport picture before you can start the registration process!",
-                                 #psm = "%s, %s" % (psm,ds),
-                                 firstlayout = True,
-                                 lastlayout = True,
-                                 ds = ds,
-                                 )
-
-if psm == 'invalid':
-    return context.clearance_pin_form(rendered = res,
-                                 psm = "Please correct your input!",
-                                 #psm = "%s, %s" % (psm,ds),
-                                 firstlayout = True,
-                                 lastlayout = True,
-                                 ds = ds,
-                                 )
-elif psm == '':
+if psm == '':
     return context.clearance_pin_form(rendered = res,
                                  psm = None,
@@ -54,16 +40,33 @@
                                  ds = ds,
                                  )
-elif psm == 'valid':
-    info = context.getStudentInfo()
-    review_state = info['review_state']
-    wf.doActionFor(info['student'],'enter_clearance_pin')
-    wf.doActionFor(info['app'],'close')
-    wf.doActionFor(info['clear'],'open')
-    pin = str(ds.get('clr_ac_pin'))
-    dc = {}
-    dc['clr_ac_pin'] = pin
-    dc['clr_ac_date'] = current
-    dc['entry_date'] = current
-    dc['entry_session'] = "2006/2007"
-    info['clear_doc'].edit(mapping = dc)
+error = False
+if app_doc.passport is None:
+    psm = "You must upload your passport picture before you can start the registration process!"
+    error = True
+elif review_state == "clearance_pin_entered":
+    psm = "You have already entered a clearance pin"
+    error = True
+elif psm == 'invalid':
+    psm = "Please correct your input!",
+    error = True
+if error:
+    return context.clearance_pin_form(rendered = res,
+                                 psm = psm,
+                                 firstlayout = True,
+                                 lastlayout = True,
+                                 ds = ds,
+                                 )
+pin = str(ds.get('clr_ac_pin'))
+logger.info('"%s", "%s"' % (info['id'],pin))
+wf.doActionFor(info['student'],'enter_clearance_pin')
+wf.doActionFor(info['clear'],'open')
+dc = {}
+app_doc = info['app_doc']
+dc['lga_ident'] = app_doc.get('jamb_lga')
+dc['lga'] = app_doc.get('jamb_state','no state') + ' / ' + app_doc.get('jamb_lga','no lga') 
+dc['clr_ac_date'] = current
+dc['entry_date'] = current
+dc['entry_session'] = "2006/2007"
+wf.doActionFor(info['app'],'close')
+info['clear_doc'].edit(mapping = dc)
 return redirect("%s/clearance_edit_form" % info['clear'].absolute_url())
