Index: WAeUP_SRP/trunk/skins/waeup_futminna/application_edit.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_futminna/application_edit.py	(revision 6986)
+++ WAeUP_SRP/trunk/skins/waeup_futminna/application_edit.py	(revision 6986)
@@ -0,0 +1,85 @@
+## Script (Python) "application_edit"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=REQUEST, cpsdocument_edit_and_view_button=None, action=None, portal_status_message=''
+##title=
+# $Id$
+"""
+"""
+wftool = context.portal_workflow
+from urllib import urlencode
+from Products.CPSDocument.utils import getFormUidUrlArg
+import DateTime
+current = DateTime.DateTime()
+import logging
+logger = logging.getLogger('Skins.application_edit')
+
+psm = ""
+args = {}
+
+info = context.getApplicationInfo()
+
+student = info['student']
+
+if info is None:
+    logger.info('Anonymous user tried to access %s' % REQUEST.get('URL0'))
+    return REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
+
+if info['has_passport'] and info['app_doc'].app_email:
+    logger.info('%s proceeded to start clearance' % (info['id']))
+    #personal_doc = student.personal.getContent()
+    #try:
+    #    wftool.doActionFor(student.personal,'open')
+    #except:
+    #    pass
+    #personal_doc.edit(mapping = {'email' : info['app_doc'].app_email})
+    #wftool.doActionFor(student.personal,'close')
+    action = "/start_clearance"
+    base_url = student.absolute_url()
+    url = base_url + action
+    return REQUEST.RESPONSE.redirect(url)
+elif not cpsdocument_edit_and_view_button:
+    action = "/application_edit_form"
+    base_url = student.absolute_url()
+    #url = base_url + action
+    if portal_status_message:
+        args['portal_status_message'] = portal_status_message
+        url = base_url + action + '?' + urlencode(args)
+    else:
+        url = base_url + action
+    return REQUEST.RESPONSE.redirect(url)
+
+
+
+app = info['app']
+app_doc = info['app_doc']
+state = info['review_state']
+
+app_review_state = wftool.getInfoFor(app,'review_state',None)
+if app_review_state != 'opened':
+    wftool.doActionFor(app,'open')
+
+is_valid, ds = app_doc.validate(request=REQUEST,
+                                schema_id = 'student_application',
+                                layout_id = 'student_application',
+                                proxy=app,
+                                use_session=False)
+
+
+action = "/application_edit"
+base_url = app.absolute_url()
+
+if is_valid:
+    args['portal_status_message'] = "You didn't upload all required data!"
+
+else:
+    args['portal_status_message'] = "Please correct your error!"
+
+url = base_url + action + '?' + urlencode(args)
+
+
+  
+return REQUEST.RESPONSE.redirect(url)
