Index: WAeUP_SRP/trunk/skins/waeup_student/application_edit.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/application_edit.pt	(revision 787)
+++ 	(revision )
@@ -1,26 +1,0 @@
-<metal:html tal:define="info context/getStudentInfo;
-            rendered_main python:info['app_doc'].renderEdit(
-                                                        request=request,
-                                                        layout_mode='edit',
-                                                        proxy=info['app'],
-                                                        no_form = True,
-                                                        schema_id = 'student_application',
-                                                        layout_id='student_application_fe',
-            )">
-  <metal:body use-macro="here/main_template/macros/master">
-    <metal:main fill-slot="main">
-      <span tal:condition="not: info">
-        <metal:block use-macro="here/error_not_found/macros/not_found" />
-      </span>
-      <span tal:condition="python: context.portal_type != 'Student'"> 
-        <span tal:define="dummy python: request.RESPONSE.redirect('%s' % info['url'])" />
-      </span>
-      <span tal:condition="info"
-            tal:define="review_state info/review_state">
-        <h3>Upload or Change your Passport Picture!</h3>
-        <br />
-        <span tal:omit-tag="" tal:replace="structure rendered_main"/>
-      </span>
-    </metal:main>
-  </metal:body>
-</metal:html>
Index: WAeUP_SRP/trunk/skins/waeup_student/application_edit.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/application_edit.py	(revision 788)
+++ WAeUP_SRP/trunk/skins/waeup_student/application_edit.py	(revision 788)
@@ -0,0 +1,58 @@
+## Script (Python) "cpsdocument_edit"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=REQUEST,proceed=None, cpsdocument_edit_button=None, action=None
+##title=
+# $Id$
+"""
+"""
+wftool = context.portal_workflow
+from urllib import urlencode
+from Products.CPSDocument.utils import getFormUidUrlArg
+import DateTime
+current = DateTime.DateTime()
+
+# 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
+# (We don't call getEditableContent here, validate does it when needed.)
+info = context.getStudentInfo()
+
+student = info['student']
+app = info['app']
+app_doc = info['app_doc']
+clear = info['clear']
+clear_doc = info['clear_doc']
+state = context.getStudentInfo()['review_state']
+is_valid, ds = app_doc.validate(request=REQUEST, 
+                                schema_id = 'student_application',
+                                layout_id = 'student_application_fe',
+                                proxy=app,
+                                use_session=True)
+
+psm = ""
+args = {}
+action = "/application_edit_view"
+if cpsdocument_edit_button:
+    if is_valid:
+        if app_doc.passport is not None:
+            args['proceed'] = 'Continue to Clearance'
+            psm = 'You successfully uploaded your passport image.'
+        else:
+            psm = "You didn't upload a passport image."
+elif proceed:
+    if is_valid:
+        action = "/request_clearance"
+    else:
+        psm = 'psm_content_error'
+args['portal_status_message'] = psm
+url = app.absolute_url() + action + '?' + urlencode(args)
+REQUEST.RESPONSE.redirect(url)
Index: WAeUP_SRP/trunk/skins/waeup_student/application_edit_view.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/application_edit_view.pt	(revision 788)
+++ WAeUP_SRP/trunk/skins/waeup_student/application_edit_view.pt	(revision 788)
@@ -0,0 +1,21 @@
+<metal:html tal:define="info context/getStudentInfo;
+            rendered_main python:info['app_doc'].render(layout_mode='edit',
+                      proceed = request.get('proceed'),
+                      schema_id = 'student_application',
+                      layout_id = 'student_application_fe',
+                      request=request, proxy=info['app'],
+                      use_session=True, no_form=True)">
+  <metal:body use-macro="here/main_template/macros/master">
+    <metal:main fill-slot="main">
+      <span tal:condition="not: info">
+        <metal:block use-macro="here/error_not_found/macros/not_found" />
+      </span>
+      <span tal:condition="info"
+            tal:define="review_state info/review_state">
+        <h3>Upload or Change your Passport Picture!</h3>
+        <br />
+        <span tal:omit-tag="" tal:replace="structure rendered_main"/>
+      </span>
+    </metal:main>
+  </metal:body>
+</metal:html>
Index: WAeUP_SRP/trunk/skins/waeup_student/check_admission.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/check_admission.py	(revision 787)
+++ WAeUP_SRP/trunk/skins/waeup_student/check_admission.py	(revision 788)
@@ -5,8 +5,7 @@
 """
 import DateTime
+from urllib import urlencode
 current = DateTime.DateTime()
 pr = context.portal_registration
-
-
 type_name = 'StudentApplication'
 ti = context.portal_types[type_name]
@@ -45,4 +44,5 @@
 elif psm == 'valid':
     s_id = ds.get('s_id')
+    email = ds.get('app_email')
     student = getattr(context.campus.students, s_id)
     review_state = wf.getInfoFor(student,'review_state',None)
@@ -51,5 +51,9 @@
         return redirect(url)
     pin = str(ds.get('app_ac_pin'))
-    return redirect("%s/logged_in?__ac_name=%s&__ac_password=%s&pin=%s"
-          % (context.absolute_url(),s_id,pin.split('-')[2],pin))
-return
+    args = {}
+    args['__ac_name'] = s_id
+    args['__ac_password'] = pin.split('-')[2]
+    args['pin'] = pin
+    args['email'] = email
+    url = "%s/logged_in?%s" % (context.absolute_url(),urlencode(args))
+    return redirect(url)
Index: WAeUP_SRP/trunk/skins/waeup_student/clearance_edit.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/clearance_edit.pt	(revision 787)
+++ 	(revision )
@@ -1,44 +1,0 @@
-<tal:block define="
-           info context/getStudentInfo;
-           res python:info['clear_doc'].renderEditDetailed(request=request,
-                                                      schema_id='student_clearance',
-                                                      layout_id='student_clearance_fe',
-                                                      layout_mode='edit',);
-           rendered_main python: res[0];
-           form_action string:clearance_edit;
-           edition python:True;
-           metadata nothing;
-    ">
-<metal:block define-macro="edit_form">
-<metal:block use-macro="here/content_lib_master/macros/master">
-
-
-  <metal:block fill-slot="header">
-    <h3>
-      Edit your Clearance Data!
-    </h3>
-  </metal:block>
-
-  <metal:block fill-slot="main">
-    <form action="ACTION" method="post" id="editForm"
-          enctype="multipart/form-data" class="workflow"
-          tal:attributes="action form_action">
-      <div class="group">
-        <div class="documentFields">
-          <tal:block define="getFormUidHtml nocall:modules/Products.CPSDocument.utils/getFormUidHtml"
-                     replace="structure python:getFormUidHtml(request)"/>
-          
-          <input type="hidden" id="button_placeholder" name="button_placeholder" value="" />
-          <div id="rendered_main" tal:content="structure rendered_main">
-            CONTENT
-          </div>
-        </div>
-          
-               
-      </div>
-    </form>
-  </metal:block>
-
-</metal:block>
-</metal:block>
-</tal:block>
Index: WAeUP_SRP/trunk/skins/waeup_student/clearance_edit.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/clearance_edit.py	(revision 788)
+++ WAeUP_SRP/trunk/skins/waeup_student/clearance_edit.py	(revision 788)
@@ -0,0 +1,52 @@
+## Script (Python) "cpsdocument_edit"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=REQUEST,proceed=None, cpsdocument_edit_button=None, action=None
+##title=
+# $Id: student_edit.py 770 2006-10-29 05:24:04Z henrik $
+"""
+"""
+wftool = context.portal_workflow
+from urllib import urlencode
+from Products.CPSDocument.utils import getFormUidUrlArg
+import DateTime
+current = DateTime.DateTime()
+
+# 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
+# (We don't call getEditableContent here, validate does it when needed.)
+info = context.getStudentInfo()
+
+student = info['student']
+app = info['app']
+app_doc = info['app_doc']
+clear = info['clear']
+clear_doc = info['clear_doc']
+state = context.getStudentInfo()['review_state']
+is_valid, ds = clear_doc.validate(request=REQUEST, 
+                                schema_id = 'student_clearance',
+                                layout_id = 'student_clearance_fe',
+                                proxy=clear,
+                                use_session=True)
+
+psm = ""
+args = {}
+action = "/clearance_edit_view"
+if cpsdocument_edit_button:
+    if is_valid:
+        psm = 'Content changed.'
+    else:
+        args = getFormUidUrlArg(REQUEST)
+        psm = "Please correct Your errors."
+args['portal_status_message'] = psm
+url = clear.absolute_url() + action + '?' + urlencode(args)
+REQUEST.RESPONSE.redirect(url)
Index: WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_view.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_view.pt	(revision 788)
+++ WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_view.pt	(revision 788)
@@ -0,0 +1,93 @@
+<tal:block define="
+           info context/getStudentInfo;
+           rendered_main python:info['clear_doc'].render(request=request,
+                                               layout_mode = 'edit',
+                                               schema_id='student_clearance',
+                                               layout_id='student_clearance_fe',
+                                               layout_mode='edit',);
+           form_action string:clearance_edit;
+           edition python:True;
+           creation python:False;
+           metadata nothing;
+    ">
+<metal:block define-macro="edit_form">
+<metal:block use-macro="here/content_lib_master/macros/master">
+  <metal:block fill-slot="style_slot">
+    <link rel="Stylesheet" type="text/css" href=""
+      tal:attributes="href string:${base_url}document.css" />
+
+    <metal:block define-macro="widgets_javascript">
+    <!-- XXX this has to move to CPSSchemas -->
+    <style type="text/css"
+      tal:content="string:@import url(${base_url}calendar-win2k-1.css);"></style>
+    <script type="text/javascript" src="calendar.js"
+      tal:attributes="src string:${base_url}calendar.js"></script>
+    <script type="text/javascript" src="lang/calendar-en.js"
+      tal:define="local cpsmcat/getSelectedLanguage"
+      tal:attributes="src string:${base_url}lang/calendar-${local}.js"></script>
+    <script type="text/javascript" src="calendar-setup.js"
+      tal:attributes="src string:${base_url}calendar-setup.js"></script>
+    <script type="text/javascript" src="prototype.js"
+      tal:attributes="src string:${base_url}prototype.js"></script>
+    <script type="text/javascript" src="effects.js"
+      tal:attributes="src string:${base_url}effects.js"></script>
+    <script type="text/javascript" src="controls.js"
+      tal:attributes="src string:${base_url}controls.js"></script>
+    <script type="text/javascript" src="cpsdocument.js"
+      tal:attributes="src string:${base_url}cpsdocument.js"></script>
+    <tal:block condition="python:modules['Products.CPSUtil.integration'].isProductPresent('Products.FCKeditor')">
+      <script type="text/javascript">
+        var popup_editor_form = 'popup_fckeditor_form';
+        var width = 640;
+        var height = 520;
+      </script>
+    </tal:block>
+    <tal:block condition="python:modules['Products.CPSUtil.integration'].isProductPresent('Products.Epoz')">
+      <script type="text/javascript">
+        var popup_editor_form = 'popup_rte_form';
+        var width = 640;
+        var height = 480;
+      </script>
+    </tal:block>
+    <script type="text/javascript">
+     function popup_rte(input_id, label_edit) {
+       var args, value;
+       value = document.getElementById(input_id).value;
+       args = '?input_id='+input_id+'&amp;label_edit='+escape(label_edit);
+       str_window_features = 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,dependent=1,width=' + width + ',height=' + height;
+       popup = window.open(popup_editor_form + args, input_id, str_window_features);
+       if (!popup.opener) {
+         popup.opener = window;
+       }
+       return false;
+     }
+   </script>
+   </metal:block>
+  </metal:block>
+
+    <h1> Edit your clearance Data</h1>
+
+  <metal:block fill-slot="main">
+    <form action="ACTION" method="post" id="editForm"
+          enctype="multipart/form-data" class="workflow"
+          tal:attributes="action form_action">
+      <div class="group">
+        <div class="documentFields">
+          <tal:block define="getFormUidHtml nocall:modules/Products.CPSDocument.utils/getFormUidHtml"
+                     replace="structure python:getFormUidHtml(request)"/>
+          <input type="hidden" id="button_placeholder" name="button_placeholder" value="" />
+          <div id="rendered_main" tal:content="structure rendered_main">
+            CONTENT
+          </div>
+        </div>
+        <metal:block use-macro="here/cpsdocument_edit_buttons/macros/buttons"/>
+      </div>
+    </form>
+    <div id="ajax_psm" style="display:none">
+      ajax feedback
+    </div>
+  </metal:block>
+
+</metal:block>
+</metal:block>
+</tal:block>
Index: WAeUP_SRP/trunk/skins/waeup_student/clearance_pin_form.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/clearance_pin_form.pt	(revision 787)
+++ WAeUP_SRP/trunk/skins/waeup_student/clearance_pin_form.pt	(revision 788)
@@ -20,6 +20,4 @@
           <ul>
             <li>Buy a Clearance Scratch Card.</li> 
-            <li>Enter your JAMB registration number and the Clearance PIN above.</li> 
-            <li>Upload your passport picture.</li> 
             <li>Apply</li>
           </ul>
Index: WAeUP_SRP/trunk/skins/waeup_student/defer_view.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/defer_view.pt	(revision 787)
+++ WAeUP_SRP/trunk/skins/waeup_student/defer_view.pt	(revision 788)
@@ -30,12 +30,10 @@
       <table tal:define="sc python: info['course_doc']">
         <tr>
+          <td tal:content="sc/title" /> <td>ID: <span tal:content="sc/study_course" /></td>
+        </tr>
+        <tr>
           <td tal:content="sc/title" /> <td tal:content="sc/study_course" />
         </tr>
       </table>
-        <span tal:condition="python:0" tal:omit-tag=""
-              tal:content="structure python: info['course_doc'].render(proxy=info['course_doc'],
-              layout_mode='view_student_course', 
-              layout_id='student_study_course')" 
-              />
       
       <form action="." method="post" class="group"
@@ -51,6 +49,6 @@
                        (cpsmcat('confirm that you defer'), )" 
                        />
-                <input type="submit" name="request_clearance:method"
-                       class="context" value="request Clearance" 
+                <input type="submit" name="application_edit:method"
+                       class="context" value="upload Passport" 
                        />
             </td>
Index: WAeUP_SRP/trunk/skins/waeup_student/layout_application_edit.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/layout_application_edit.pt	(revision 787)
+++ WAeUP_SRP/trunk/skins/waeup_student/layout_application_edit.pt	(revision 788)
@@ -6,5 +6,5 @@
   ds options/datastructure;
   dm ds/getDataModel;
-  formaction options/formaction|string:student_edit;
+  formaction options/formaction|string:application_edit;
   creation creation|nothing;
   metadata metadata|nothing;
@@ -12,5 +12,5 @@
   ti python:type_name and getattr(here.portal_types,type_name,None) or getattr(here.portal_types,here.portal_type,None);
   cpsmcat nocall:here/translation_service;
-  apply request/apply_button|nothing;
+  proceed options/proceed|nothing;
   widgets python:context.getRenderedWidgets(layout);
   ">
@@ -121,9 +121,9 @@
          id="cpsdocument_edit_button"
          tal:condition="not:creation" />
-  <input type="submit" class="standalone" name="apply_admission"
+  <input type="submit" class="standalone" name="proceed"
          value="apply for admission"
          id="cpsdocument_edit_and_view_button"
-         tal:condition="apply" 
-         tal:attributes="value apply"/>
+         tal:condition="proceed" 
+         tal:attributes="value proceed"/>
   <input type="submit" 
          class="standalone" 
Index: WAeUP_SRP/trunk/skins/waeup_student/layout_clearance_edit.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/layout_clearance_edit.pt	(revision 788)
+++ WAeUP_SRP/trunk/skins/waeup_student/layout_clearance_edit.pt	(revision 788)
@@ -0,0 +1,89 @@
+<!-- a layout_lib macro -->
+<!-- $Id: layout_application_edit.pt 710 2006-10-16 22:30:16Z joachim $ -->
+
+<metal:block define-macro="default_edit"
+  tal:define="layout options/layout;
+  ds options/datastructure;
+  dm ds/getDataModel;
+  formaction options/formaction|string:clearance_edit;
+  creation creation|nothing;
+  metadata metadata|nothing;
+  type_name request/type_name|nothing;
+  cpsmcat nocall:here/translation_service;
+  proceed options/proceed|nothing;
+  widgets python:context.getRenderedWidgets(layout);
+  ">
+  <form action="" id="editForm" method="post" 
+        enctype="multipart/form-data" class="workflow"
+        tal:attributes="action formaction"
+        >
+  <table class="layoutDefault" summary="Form layout"
+         tal:condition="layout/rows">
+    <span tal:repeat="row python: layout['rows']" valign="top" >
+      <span tal:repeat="cell row">
+        <tr tal:define="widget cell/widget;
+              wid widget/getWidgetId;
+              err python:ds.getError(wid);
+              err_mapping python:ds.getErrorMapping(wid);
+              is_required python: widget.is_required;
+              tooltip_id python:wid + '_help';
+              widget_css_class cell/widget_css_class|nothing;
+              css_class python:test(err, 'row error','row')"
+              tal:condition="python: wid != 'passport'"
+              >
+          <div tal:attributes="class widget_css_class;
+          id python:widget.getHtmlWidgetId()+'_widget';"
+          >
+            <td>
+            <div class="label" tal:condition="widget/label_edit"
+                 tal:attributes="class python:test(is_required, 'label required','label')">
+              <label tal:content="widget/label_edit"
+                     tal:attributes="for cell/widget_input_area_id|nothing;">label</label>:
+            </div>
+            <button type="button" class="tooltipControl"
+                    tal:condition="widget/help"
+                    tal:attributes="onclick python:'toggleElementVisibility(\'%s\')' % tooltip_id;"> ? </button>
+            </td>
+            <td>
+            <span class="field">
+              <div tal:replace="structure cell/widget_rendered"/>
+            </span>
+            <div class="tooltipArea" style="visibility: hidden;"
+                 tal:condition="widget/help"
+                 tal:attributes="id tooltip_id;
+                 onclick python:'showElement(false, \'%s\')' % tooltip_id;"
+                 >
+              <tal:block tal:content="widget/help">This is the help for this field
+              </tal:block>
+            </div>
+            <tal:block condition="python:err">
+              <tal:block define="msg python:cpsmcat(err, mapping=err_mapping)">
+                <br /><em style="color: red"
+                          tal:content="msg">err</em>
+              </tal:block>
+            </tal:block>
+            </td>
+          </div>
+        </tr>
+      </span>
+    </span>
+  </table>
+  <br />
+  <input type="submit" class="standalone" name="cpsdocument_edit_button"
+         value="Save" 
+         id="cpsdocument_edit_button"
+         tal:condition="not:creation" />
+  <input type="submit" class="standalone" name="proceed"
+         value="apply for admission"
+         id="cpsdocument_edit_and_view_button"
+         tal:condition="proceed" 
+         tal:attributes="value proceed"/>
+  <input type="submit" 
+         class="standalone" 
+         name="cpsdocument_create_button"
+         value="apply"
+         tal:attributes="value options/button"
+         tal:condition="creation" />
+
+</form>
+</metal:block>
Index: WAeUP_SRP/trunk/skins/waeup_student/request_clearance.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/request_clearance.py	(revision 788)
+++ WAeUP_SRP/trunk/skins/waeup_student/request_clearance.py	(revision 788)
@@ -0,0 +1,54 @@
+##parameters=REQUEST
+# $Id: apply_admission.py 649 2006-10-11 06:24:39Z joachim $
+"""
+request Clearance
+"""
+import DateTime
+current = DateTime.DateTime()
+pr = context.portal_registration
+
+type_name = 'Student'
+ti = context.portal_types[type_name]
+REQUEST.set('type_name',type_name)
+redirect = REQUEST.RESPONSE.redirect
+wf = context.portal_workflow
+validate = REQUEST.has_key("cpsdocument_create_button")
+
+lt = context.portal_layouts
+pr = context.portal_registration
+
+res,psm,ds = lt.renderLayout(layout_id='student_clearance',
+                      schema_id= 'student_clearance',
+                      context=context,
+                      mapping=validate and REQUEST,
+                      ob={},
+                      layout_mode='create',
+                      formaction = "request_clearance",
+                      button = "Request Clearance",
+                      )
+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 == '':
+    return context.clearance_pin_form(rendered = res,
+                                 psm = None,
+                                 firstlayout = True,
+                                 lastlayout = True,
+                                 ds = ds,
+                                 )
+elif psm == 'valid':
+    info = context.getStudentInfo()
+    review_state = info['review_state']
+    wf.doActionFor(info['student'],'enter_clearance_pin')
+    wf.doActionFor(info['clear'],'open')
+    pin = str(ds.get('clr_ac_pin'))
+    dc = {}
+    dc['clr_ac_pin'] = pin
+    dc['clr_ac_date'] = current
+    info['clear_doc'].edit(mapping = dc)
+return redirect("%s/clearance_edit_view" % info['clear'].absolute_url())
Index: WAeUP_SRP/trunk/skins/waeup_student/student_index.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/student_index.py	(revision 787)
+++ WAeUP_SRP/trunk/skins/waeup_student/student_index.py	(revision 788)
@@ -33,5 +33,5 @@
         return redirect("%s/application_view" % student.absolute_url())
     elif state in ('application_pin_entered',):
-        return redirect("%s/application_edit" % student.absolute_url())
+        return redirect("%s/application_edit" % info['app'].absolute_url())
     elif state in ('admitted',):
         return redirect("%s/defer_view" % student.absolute_url())
