1 | ##parameters=REQUEST |
---|
2 | # $Id: check_admission.py 173 2005-11-15 16:28:29Z joachim $ |
---|
3 | """ |
---|
4 | process the Admission Form |
---|
5 | return html renderer + psm |
---|
6 | """ |
---|
7 | import DateTime |
---|
8 | current = DateTime.DateTime() |
---|
9 | |
---|
10 | |
---|
11 | type_name = 'Jamb' |
---|
12 | ti = context.portal_types[type_name] |
---|
13 | |
---|
14 | REQUEST.set('type_name',type_name) |
---|
15 | |
---|
16 | validate = REQUEST.has_key("cpsdocument_edit_button") |
---|
17 | |
---|
18 | |
---|
19 | lt = context.portal_layouts |
---|
20 | pr = context.portal_registration |
---|
21 | |
---|
22 | res,psm,ds = lt.renderLayout(layout_id= 'admission', |
---|
23 | schema_id= 'student_admission', |
---|
24 | context=context, |
---|
25 | mapping=validate and REQUEST, |
---|
26 | ob={}, |
---|
27 | layout_mode='create', |
---|
28 | action = "check_admission", |
---|
29 | submit = "check", |
---|
30 | ) |
---|
31 | if psm == 'invalid': |
---|
32 | return context.check_admission_form(rendered = res, |
---|
33 | psm = "Please correct your input", |
---|
34 | ds = ds, |
---|
35 | ) |
---|
36 | elif psm == '': |
---|
37 | return context.check_admission_form(rendered = res, |
---|
38 | psm = None, |
---|
39 | ds = ds, |
---|
40 | ) |
---|
41 | elif psm == 'valid': |
---|
42 | s_id = "s%s" % ds.get('jamb_id') |
---|
43 | catalog = context.portal_catalog |
---|
44 | search = catalog(SearchableText = "%s*" % s_id) |
---|
45 | student = getattr(context,s_id,None) |
---|
46 | if student is None: |
---|
47 | #if len(search) < 1: |
---|
48 | psm = "Your are not admitted" |
---|
49 | return context.check_admission_form(rendered = res, |
---|
50 | psm = psm, |
---|
51 | ds = ds, |
---|
52 | ) |
---|
53 | |
---|
54 | ds.set('sc_date',current) |
---|
55 | student.getContent().setScratchCardData('adm_check',ds) |
---|
56 | |
---|
57 | jamb = getattr(student,'JAMB') |
---|
58 | res = jamb.getContent().render(layout_id = 'admission_slip', |
---|
59 | layout_mode = 'view', |
---|
60 | schema_id = 'jamb') |
---|
61 | |
---|
62 | return context.admission_slip_form(rendered = res, dict = ds) |
---|
63 | |
---|