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 | mtool = context.portal_membership |
---|
21 | member = mtool.getAuthenticatedMember() |
---|
22 | lt = context.portal_layouts |
---|
23 | pr = context.portal_registration |
---|
24 | path_info = request.get('PATH_INFO').split('/') |
---|
25 | roles = member.getRoles() |
---|
26 | is_manager = 'Manager' in roles or 'SectionManager' in roles |
---|
27 | validate = request.has_key("cpsdocument_edit_button") |
---|
28 | items = [] |
---|
29 | default = {'search_mode': 'course', |
---|
30 | 'review_state': 'unchecked', |
---|
31 | 'search_string': '' |
---|
32 | } |
---|
33 | |
---|
34 | rend,psm,ds = lt.renderLayout(layout_id= 'academics_search', |
---|
35 | schema_id= 'academics_search', |
---|
36 | context=context, |
---|
37 | mapping=validate and request, |
---|
38 | ob=default, |
---|
39 | layout_mode='edit', |
---|
40 | formaction="searchAcademics" |
---|
41 | ) |
---|
42 | if psm == '': |
---|
43 | return context.academics_search_view(rendered = rend, |
---|
44 | psm = psm, |
---|
45 | #psm = "%s, %s" % (psm,ds), |
---|
46 | objects = items, |
---|
47 | is_manager = is_manager, |
---|
48 | ) |
---|
49 | what = ds.get('search_mode') |
---|
50 | state = ds.get('review_state') |
---|
51 | term = ds.get('search_string') |
---|
52 | if state == " ----- ": |
---|
53 | state = '' |
---|
54 | if not term and what in ('student_edit','jamb_id','name','matric_no'): |
---|
55 | return context.academics_search_view(rendered = rend, |
---|
56 | psm = "You must specify a search string", |
---|
57 | #psm = "%s, %s" % (psm,ds), |
---|
58 | objects = items, |
---|
59 | is_manager = is_manager, |
---|
60 | ) |
---|
61 | onlyreview = state and what == "review_state" |
---|
62 | items = [] |
---|
63 | res = [] |
---|
64 | portal_type_query = {'query':['Department','Course','CertificateCourse']} |
---|
65 | if onlyreview: |
---|
66 | res = catalog(portal_type=portal_type_query, |
---|
67 | review_state=state) |
---|
68 | elif what == "student_id": |
---|
69 | res = catalog(portal_type='Student', |
---|
70 | id = term.strip()) |
---|
71 | elif what == "jamb_id": |
---|
72 | res = catalog(portal_type='StudentApplication', |
---|
73 | SearchableText="%s*" % term.strip().lower()) |
---|
74 | elif what == "matric_no": |
---|
75 | res = catalog(portal_type='StudentClearance', |
---|
76 | SearchableText="%s*" % term.strip().lower()) |
---|
77 | elif what == "name": |
---|
78 | res = catalog(portal_type=portal_type_query, |
---|
79 | SearchableText="%s*" % term.strip()) |
---|
80 | if res: |
---|
81 | for r in res: |
---|
82 | row = {} |
---|
83 | if r.portal_type in ("StudentApplication","StudentPersonal"): |
---|
84 | items.append(r.getObject().aq_parent) |
---|
85 | else: |
---|
86 | items.append(r.getObject()) |
---|
87 | objects = [] |
---|
88 | if items: |
---|
89 | for item in items: |
---|
90 | objects.append(context.getStudentInfo(item)) |
---|
91 | return context.academics_search_view(rendered = rend, |
---|
92 | psm = "%d matching objects found" % len(items), |
---|
93 | #psm = "%s, %s" % (psm,ds), |
---|
94 | objects = objects, |
---|
95 | is_manager = is_manager, |
---|
96 | ) |
---|