[845] | 1 | ## Script (Python) "application_edit" |
---|
[478] | 2 | ##bind container=container |
---|
| 3 | ##bind context=context |
---|
| 4 | ##bind namespace= |
---|
| 5 | ##bind script=script |
---|
| 6 | ##bind subpath=traverse_subpath |
---|
[2920] | 7 | ##parameters=REQUEST, cpsdocument_edit_and_view_button=None, action=None, portal_status_message='' |
---|
[478] | 8 | ##title= |
---|
[486] | 9 | # $Id: application_edit.py 3749 2008-11-03 09:45:05Z henrik $ |
---|
[478] | 10 | """ |
---|
| 11 | """ |
---|
[539] | 12 | wftool = context.portal_workflow |
---|
[478] | 13 | from urllib import urlencode |
---|
| 14 | from Products.CPSDocument.utils import getFormUidUrlArg |
---|
[766] | 15 | import DateTime |
---|
| 16 | current = DateTime.DateTime() |
---|
[1016] | 17 | import logging |
---|
[1571] | 18 | logger = logging.getLogger('Skins.application_edit') |
---|
[478] | 19 | |
---|
[2920] | 20 | psm = "" |
---|
| 21 | args = {} |
---|
[478] | 22 | |
---|
[1071] | 23 | info = context.getApplicationInfo() |
---|
[478] | 24 | |
---|
[2920] | 25 | student = info['student'] |
---|
| 26 | |
---|
[1016] | 27 | if info is None: |
---|
[1866] | 28 | logger.info('Anonymous user tried to access %s' % REQUEST.get('URL0')) |
---|
[1024] | 29 | return REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) |
---|
[1017] | 30 | |
---|
[2920] | 31 | if info['has_passport'] and info['app_doc'].app_email: |
---|
| 32 | logger.info('%s proceeded to start clearance' % (info['id'])) |
---|
| 33 | action = "/start_clearance" |
---|
| 34 | base_url = student.absolute_url() |
---|
| 35 | url = base_url + action |
---|
| 36 | return REQUEST.RESPONSE.redirect(url) |
---|
| 37 | elif not cpsdocument_edit_and_view_button: |
---|
| 38 | action = "/application_edit_form" |
---|
| 39 | base_url = student.absolute_url() |
---|
| 40 | #url = base_url + action |
---|
| 41 | if portal_status_message: |
---|
| 42 | args['portal_status_message'] = portal_status_message |
---|
| 43 | url = base_url + action + '?' + urlencode(args) |
---|
| 44 | else: |
---|
| 45 | url = base_url + action |
---|
| 46 | return REQUEST.RESPONSE.redirect(url) |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | |
---|
[535] | 50 | app = info['app'] |
---|
| 51 | app_doc = info['app_doc'] |
---|
[1071] | 52 | state = info['review_state'] |
---|
[3749] | 53 | |
---|
| 54 | app_review_state = wftool.getInfoFor(app,'review_state',None) |
---|
| 55 | if app_review_state != 'opened': |
---|
| 56 | wftool.doActionFor(app,'open') |
---|
| 57 | |
---|
[796] | 58 | is_valid, ds = app_doc.validate(request=REQUEST, |
---|
[788] | 59 | schema_id = 'student_application', |
---|
[2579] | 60 | layout_id = 'student_application', |
---|
[788] | 61 | proxy=app, |
---|
[2390] | 62 | use_session=False) |
---|
[483] | 63 | |
---|
[2920] | 64 | |
---|
| 65 | action = "/application_edit" |
---|
[794] | 66 | base_url = app.absolute_url() |
---|
[796] | 67 | |
---|
[851] | 68 | if is_valid: |
---|
[2920] | 69 | args['portal_status_message'] = "You didn't upload all required data!" |
---|
| 70 | |
---|
[796] | 71 | else: |
---|
[2920] | 72 | args['portal_status_message'] = "Please correct your error!" |
---|
| 73 | |
---|
| 74 | url = base_url + action + '?' + urlencode(args) |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | return REQUEST.RESPONSE.redirect(url) |
---|