[766] | 1 | ##parameters=REQUEST |
---|
[805] | 2 | # $Id: check_admission.py 1867 2007-06-08 09:59:59Z 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 | |
---|
[1867] | 24 | res,psm,ds = lt.renderLayout('student_application_fe', |
---|
| 25 | 'student_application', |
---|
| 26 | context, |
---|
| 27 | mapping=validate and REQUEST, |
---|
| 28 | layout_mode='create', |
---|
| 29 | ob={}, |
---|
| 30 | commit=False, |
---|
| 31 | formaction = "check_admission", |
---|
| 32 | button = "Check", |
---|
| 33 | ) |
---|
[766] | 34 | if psm == 'invalid': |
---|
[785] | 35 | return context.check_admission_pin_form(rendered = res, |
---|
[892] | 36 | psm = "Please correct your input!", |
---|
[766] | 37 | #psm = "%s, %s" % (psm,ds), |
---|
| 38 | firstlayout = True, |
---|
| 39 | lastlayout = True, |
---|
| 40 | ds = ds, |
---|
| 41 | ) |
---|
| 42 | elif psm == '': |
---|
[785] | 43 | return context.check_admission_pin_form(rendered = res, |
---|
[766] | 44 | psm = None, |
---|
| 45 | firstlayout = True, |
---|
| 46 | lastlayout = True, |
---|
| 47 | ds = ds, |
---|
| 48 | ) |
---|
| 49 | elif psm == 'valid': |
---|
| 50 | s_id = ds.get('s_id') |
---|
[997] | 51 | if is_anon and not s_id: |
---|
| 52 | return context.check_admission_pin_form(rendered = res, |
---|
| 53 | psm = "You are not allowed to call this form in this context. Please try to log in.", |
---|
| 54 | #psm = "%s, %s" % (psm,ds), |
---|
| 55 | firstlayout = True, |
---|
| 56 | lastlayout = True, |
---|
| 57 | ds = ds, |
---|
| 58 | ) |
---|
| 59 | elif not is_anon: |
---|
| 60 | return context.check_admission_pin_form(rendered = res, |
---|
| 61 | psm = "You are already logged in!", |
---|
| 62 | #psm = "%s, %s" % (psm,ds), |
---|
| 63 | firstlayout = True, |
---|
| 64 | lastlayout = True, |
---|
| 65 | ds = ds, |
---|
| 66 | ) |
---|
[979] | 67 | ## |
---|
| 68 | ## email = ds.get('app_email') |
---|
[785] | 69 | student = getattr(context.campus.students, s_id) |
---|
| 70 | review_state = wf.getInfoFor(student,'review_state',None) |
---|
[797] | 71 | if review_state == "admission_rejected": |
---|
| 72 | url = "%s/campus/students/%s/pume/admission_rejected_view" % (context.portal_url(),s_id) |
---|
[785] | 73 | return redirect(url) |
---|
[992] | 74 | pin = str(ds.get('app_ac_pin_n')) |
---|
[788] | 75 | args = {} |
---|
| 76 | args['__ac_name'] = s_id |
---|
[992] | 77 | #args['__ac_password'] = pin.split('-')[2] |
---|
| 78 | args['__ac_password'] = pin |
---|
[788] | 79 | args['pin'] = pin |
---|
[979] | 80 | ## args['email'] = email |
---|
[788] | 81 | url = "%s/logged_in?%s" % (context.absolute_url(),urlencode(args)) |
---|
| 82 | return redirect(url) |
---|
[997] | 83 | |
---|