Index: WAeUP_SRP/trunk/skins/waeup_student/application_form.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/application_form.pt	(revision 478)
+++ WAeUP_SRP/trunk/skins/waeup_student/application_form.pt	(revision 479)
@@ -11,27 +11,12 @@
 
   <metal:block fill-slot="main">
-
-    <tal:block tal:condition="python:context.portal_type == 'Student'" tal:omit-tag="">  
-      <tal:block tal:define="
-                          rendered python:context.application.getContent().renderEdit(layout_id='student_application_fe',
-                                                         layout_mode='edit');"
-                          >
-
-   
+      <tal:block 
+          tal:define="rendered python:context.getContent().renderEdit(
+                layout_id='student_application_fe',
+                layout_mode='edit',
+                );">
       <tal:block tal:content="structure rendered" />
-
       </tal:block>  
-    </tal:block>
-    <tal:block condition="python:context.portal_type != 'Student'">
-    
-      This is not a student object
-      
-    
-    </tal:block>  
-  
   </metal:block>
-
-
-
   <metal:block fill-slot="sub">
   </metal:block>
Index: WAeUP_SRP/trunk/skins/waeup_student/apply_admission.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/apply_admission.py	(revision 478)
+++ WAeUP_SRP/trunk/skins/waeup_student/apply_admission.py	(revision 479)
@@ -5,24 +5,19 @@
 return html renderer + psm
 """
-import DateTime
-current = DateTime.DateTime()
-
 type_name = 'StudentApplication'
-
 ti = context.portal_types[type_name]
-
 REQUEST.set('type_name',type_name)
 
 validate = REQUEST.has_key("cpsdocument_create_button")
 
-
 lt = context.portal_layouts
 pr = context.portal_registration
 
-res,psm,ds = lt.renderLayout(layout_id= 'student_check_pin',
-                      schema_id= 'student_check_pin',
+prefix = 'APP'
+res,psm,ds = lt.renderLayout(layout_id= 'student_application_fe',
+                      schema_id= 'student_application',
                       context=context,
                       mapping=validate and REQUEST,
-                      ob={},
+                      ob={'app_ac_prefix': prefix},
                       layout_mode='create',
                       formaction = "apply_admission",
@@ -60,7 +55,8 @@
 student = application.aq_parent
 if context.portal_workflow.getInfoFor(student,'review_state',None) == "created":
-    student.invokeFactory('StudentClearance','clearance')
+    #student.invokeFactory('StudentClearance','clearance')
     student.invokeFactory('StudentPersonal','personal')
     student.content_status_modify(workflow_action="enter_application_pin")
+
 
 apdoc = application.getContent()
@@ -80,7 +76,10 @@
 student.personal.getContent().edit(mapping = dp)
 da = {}
-da['app_ac_pin'] = ds['pin']
+da['app_ac_prefix'] = prefix
+da['app_ac_batch_no'] = ds.get('app_ac_batch_no')
+da['app_ac_pin'] = ds.get('app_ac_pin')
 apdoc.edit(mapping = da)
 # now display the passport form with jamb-data readonly
+return context.REQUEST.RESPONSE.redirect("%s/application_form" % (student.application.absolute_url()))
 return student.application_form()
 
Index: WAeUP_SRP/trunk/skins/waeup_student/layout_student_create.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/layout_student_create.pt	(revision 479)
+++ WAeUP_SRP/trunk/skins/waeup_student/layout_student_create.pt	(revision 479)
@@ -0,0 +1,3 @@
+<tal:block define="global creation python:1;
+                   global formaction string:apply_admission" />
+<metal:block use-macro="here/layout_waeup_edit/macros/default_edit" />
Index: WAeUP_SRP/trunk/skins/waeup_student/student_edit.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/student_edit.py	(revision 478)
+++ WAeUP_SRP/trunk/skins/waeup_student/student_edit.py	(revision 479)
@@ -35,23 +35,50 @@
 # (We don't call getEditableContent here, validate does it when needed.)
 doc = context.getContent()
-is_valid, ds = doc.validate(request=REQUEST, proxy=context, cluster=cluster,
-                            use_session=True)
 
-if action is None:
-    ti = doc.getTypeInfo()
-    action = ti.queryMethodID('edit', 'cpsdocument_edit_form')
-    action = '/' + action
-
-if is_valid:
-    comments = REQUEST.get('comments')
-    context.cpsdocument_notify_modification(comments=comments)
-    if cpsdocument_edit_and_view_button is not None:
-        action = ''
-    psm = 'psm_content_changed'
-    args = {}
+if context.portal_type == "StudentApplication":
+    student = context.aq_parent
+    if context.portal_workflow.getInfoFor(student,'review_state',None) == "application_pin_entered":
+        student.content_status_modify(workflow_action="apply_for_admission")
+        is_valid, ds = doc.validate(request=REQUEST, 
+                                    proxy=context, 
+                                    layout_id = "student_application_fe",
+                                    layout_mode = 'edit',
+                                    use_session=True)
+        
+        action = '/application_form'
+        
+        if is_valid:
+            comments = REQUEST.get('comments')
+            context.cpsdocument_notify_modification(comments=comments)
+            if cpsdocument_edit_and_view_button is not None:
+                action = ''
+            psm = 'psm_content_changed'
+            args = {}
+        else:
+            psm = 'psm_content_error'
+            args = getFormUidUrlArg(REQUEST)
+    else:
+        psm = "Application applied waiting for results"
+        action = "/view"
 else:
-    psm = 'psm_content_error'
-    args = getFormUidUrlArg(REQUEST)
-
+    is_valid, ds = doc.validate(request=REQUEST, proxy=context, cluster=cluster,
+                                use_session=True)
+    
+    if action is None:
+        ti = doc.getTypeInfo()
+        action = ti.queryMethodID('edit', 'cpsdocument_edit_form')
+        action = '/' + action
+    
+    if is_valid:
+        comments = REQUEST.get('comments')
+        context.cpsdocument_notify_modification(comments=comments)
+        if cpsdocument_edit_and_view_button is not None:
+            action = ''
+        psm = 'psm_content_changed'
+        args = {}
+    else:
+        psm = 'psm_content_error'
+        args = getFormUidUrlArg(REQUEST)
+    
 args['portal_status_message'] = psm
 url = context.absolute_url() + action + '?' + urlencode(args)
