1 | ## Script (Python) "cpsdocument_edit" |
---|
2 | ##bind container=container |
---|
3 | ##bind context=context |
---|
4 | ##bind namespace= |
---|
5 | ##bind script=script |
---|
6 | ##bind subpath=traverse_subpath |
---|
7 | ##parameters= |
---|
8 | ##title= |
---|
9 | ## |
---|
10 | # $Id: student_edit.py 486 2006-09-06 10:09:39Z joachim $ |
---|
11 | """ |
---|
12 | return Info about the current Student |
---|
13 | """ |
---|
14 | request = context.REQUEST |
---|
15 | form = request.form |
---|
16 | fget = form.get |
---|
17 | info = {} |
---|
18 | wf = context.portal_workflow |
---|
19 | catalog = context.portal_catalog |
---|
20 | student_wf_states = wf.waeup_student_wf.states.keys() |
---|
21 | info['wf_states'] = student_wf_states |
---|
22 | info['wf_states'][0] = " ----- " |
---|
23 | mtool = context.portal_membership |
---|
24 | member = mtool.getAuthenticatedMember() |
---|
25 | lt = context.portal_layouts |
---|
26 | pr = context.portal_registration |
---|
27 | path_info = request.get('PATH_INFO').split('/') |
---|
28 | roles = member.getRoles() |
---|
29 | is_manager = 'Manager' in roles or 'SectionManager' in roles |
---|
30 | validate = request.has_key("cpsdocument_edit_button") |
---|
31 | items = [] |
---|
32 | default = {'search_mode': 'name', |
---|
33 | 'review_state': 'admission_applied ', |
---|
34 | 'search_string': 'yy' |
---|
35 | } |
---|
36 | |
---|
37 | rend,psm,ds = lt.renderLayout(layout_id= 'student_search', |
---|
38 | schema_id= 'student_search', |
---|
39 | context=context, |
---|
40 | mapping=validate and request, |
---|
41 | ob=default, |
---|
42 | layout_mode='edit', |
---|
43 | formaction="searchStudents" |
---|
44 | ) |
---|
45 | if psm == '': |
---|
46 | return context.students_manager_view(rendered = rend, |
---|
47 | psm = psm, |
---|
48 | #psm = "%s, %s" % (psm,ds), |
---|
49 | students = items, |
---|
50 | is_manager = is_manager, |
---|
51 | ) |
---|
52 | what = ds.get('search_mode') |
---|
53 | state = ds.get('review_state') |
---|
54 | term = ds.get('search_string') |
---|
55 | if state == " ----- ": |
---|
56 | state = '' |
---|
57 | onlyreview = state and what == "review_state" |
---|
58 | items = [] |
---|
59 | res = [] |
---|
60 | portal_type_query = {'query':['Student','StudentApplication','StudentPersonal']} |
---|
61 | if onlyreview: |
---|
62 | res = catalog(portal_type=portal_type_query, |
---|
63 | review_state=state) |
---|
64 | elif what == "student_id": |
---|
65 | res = catalog(portal_type='Student', |
---|
66 | id = student_id.strip()) |
---|
67 | elif what == "jamb_id": |
---|
68 | res = catalog(portal_type='StudentApplication', |
---|
69 | SearchableText="%s*" % term.strip().lower()) |
---|
70 | elif what == "matric_no": |
---|
71 | res = catalog(portal_type='StudentClearance', |
---|
72 | SearchableText="%s*" % term.strip().lower()) |
---|
73 | elif what == "name": |
---|
74 | res = catalog(portal_type=portal_type_query, |
---|
75 | SearchableText="%s*" % term.strip()) |
---|
76 | if res: |
---|
77 | for r in res: |
---|
78 | row = {} |
---|
79 | if r.portal_type in ("StudentApplication","StudentPersonal"): |
---|
80 | items.append(r.getObject().aq_parent) |
---|
81 | else: |
---|
82 | items.append(r.getObject()) |
---|
83 | students = [] |
---|
84 | if items: |
---|
85 | for item in items: |
---|
86 | students.append(context.getStudentInfo(item)) |
---|
87 | return context.students_manager_view(rendered = rend, |
---|
88 | psm = "%d matching Students found" % len(items), |
---|
89 | #psm = "%s, %s" % (psm,ds), |
---|
90 | students = students, |
---|
91 | is_manager = is_manager, |
---|
92 | ) |
---|