[766] | 1 | ##parameters=REQUEST |
---|
[805] | 2 | # $Id: check_admission.py 1000 2006-12-06 11:46:11Z joachim $ |
---|
[766] | 3 | """ |
---|
| 4 | request Clearance |
---|
| 5 | """ |
---|
| 6 | import DateTime |
---|
[788] | 7 | from urllib import urlencode |
---|
[766] | 8 | current = DateTime.DateTime() |
---|
| 9 | pr = context.portal_registration |
---|
| 10 | type_name = 'StudentApplication' |
---|
| 11 | ti = context.portal_types[type_name] |
---|
| 12 | REQUEST.set('type_name',type_name) |
---|
[785] | 13 | redirect = REQUEST.RESPONSE.redirect |
---|
| 14 | wf = context.portal_workflow |
---|
[766] | 15 | validate = REQUEST.has_key("cpsdocument_create_button") |
---|
| 16 | |
---|
[992] | 17 | mtool = context.portal_membership |
---|
| 18 | is_anon = mtool.isAnonymousUser() |
---|
| 19 | member = mtool.getAuthenticatedMember() |
---|
| 20 | |
---|
[766] | 21 | lt = context.portal_layouts |
---|
| 22 | pr = context.portal_registration |
---|
| 23 | |
---|
| 24 | res,psm,ds = lt.renderLayout(layout_id= 'student_application_fe', |
---|
| 25 | schema_id= 'student_application', |
---|
| 26 | context=context, |
---|
| 27 | mapping=validate and REQUEST, |
---|
| 28 | ob={}, |
---|
| 29 | layout_mode='create', |
---|
[785] | 30 | formaction = "check_admission", |
---|
[799] | 31 | button = "Check", |
---|
[766] | 32 | ) |
---|
| 33 | if psm == 'invalid': |
---|
[785] | 34 | return context.check_admission_pin_form(rendered = res, |
---|
[892] | 35 | psm = "Please correct your input!", |
---|
[766] | 36 | #psm = "%s, %s" % (psm,ds), |
---|
| 37 | firstlayout = True, |
---|
| 38 | lastlayout = True, |
---|
| 39 | ds = ds, |
---|
| 40 | ) |
---|
| 41 | elif psm == '': |
---|
[785] | 42 | return context.check_admission_pin_form(rendered = res, |
---|
[766] | 43 | psm = None, |
---|
| 44 | firstlayout = True, |
---|
| 45 | lastlayout = True, |
---|
| 46 | ds = ds, |
---|
| 47 | ) |
---|
| 48 | elif psm == 'valid': |
---|
| 49 | s_id = ds.get('s_id') |
---|
[997] | 50 | if is_anon and not s_id: |
---|
| 51 | return context.check_admission_pin_form(rendered = res, |
---|
| 52 | psm = "You are not allowed to call this form in this context. Please try to log in.", |
---|
| 53 | #psm = "%s, %s" % (psm,ds), |
---|
| 54 | firstlayout = True, |
---|
| 55 | lastlayout = True, |
---|
| 56 | ds = ds, |
---|
| 57 | ) |
---|
| 58 | elif not is_anon: |
---|
| 59 | return context.check_admission_pin_form(rendered = res, |
---|
| 60 | psm = "You are already logged in!", |
---|
| 61 | #psm = "%s, %s" % (psm,ds), |
---|
| 62 | firstlayout = True, |
---|
| 63 | lastlayout = True, |
---|
| 64 | ds = ds, |
---|
| 65 | ) |
---|
[979] | 66 | ## |
---|
| 67 | ## email = ds.get('app_email') |
---|
[785] | 68 | student = getattr(context.campus.students, s_id) |
---|
| 69 | review_state = wf.getInfoFor(student,'review_state',None) |
---|
[797] | 70 | if review_state == "admission_rejected": |
---|
| 71 | url = "%s/campus/students/%s/pume/admission_rejected_view" % (context.portal_url(),s_id) |
---|
[785] | 72 | return redirect(url) |
---|
[992] | 73 | pin = str(ds.get('app_ac_pin_n')) |
---|
[788] | 74 | args = {} |
---|
| 75 | args['__ac_name'] = s_id |
---|
[992] | 76 | #args['__ac_password'] = pin.split('-')[2] |
---|
| 77 | args['__ac_password'] = pin |
---|
[788] | 78 | args['pin'] = pin |
---|
[979] | 79 | ## args['email'] = email |
---|
[788] | 80 | url = "%s/logged_in?%s" % (context.absolute_url(),urlencode(args)) |
---|
| 81 | return redirect(url) |
---|
[997] | 82 | |
---|