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