[565] | 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 |
---|
[584] | 7 | ##parameters= |
---|
[565] | 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 | """ |
---|
[589] | 14 | #from Products.ZCTextIndex.QueryParser import ParseError,QueryError |
---|
[565] | 15 | request = context.REQUEST |
---|
| 16 | form = request.form |
---|
| 17 | fget = form.get |
---|
[572] | 18 | info = {} |
---|
[565] | 19 | wf = context.portal_workflow |
---|
[572] | 20 | catalog = context.portal_catalog |
---|
| 21 | student_wf_states = wf.waeup_student_wf.states.keys() |
---|
| 22 | info['wf_states'] = student_wf_states |
---|
| 23 | info['wf_states'][0] = " ----- " |
---|
[565] | 24 | mtool = context.portal_membership |
---|
| 25 | member = mtool.getAuthenticatedMember() |
---|
[584] | 26 | lt = context.portal_layouts |
---|
| 27 | pr = context.portal_registration |
---|
[565] | 28 | path_info = request.get('PATH_INFO').split('/') |
---|
| 29 | roles = member.getRoles() |
---|
[584] | 30 | is_manager = 'Manager' in roles or 'SectionManager' in roles |
---|
| 31 | validate = request.has_key("cpsdocument_edit_button") |
---|
| 32 | items = [] |
---|
| 33 | default = {'search_mode': 'name', |
---|
| 34 | 'review_state': 'admission_applied ', |
---|
[587] | 35 | 'search_string': '' |
---|
[584] | 36 | } |
---|
| 37 | |
---|
| 38 | rend,psm,ds = lt.renderLayout(layout_id= 'student_search', |
---|
| 39 | schema_id= 'student_search', |
---|
| 40 | context=context, |
---|
| 41 | mapping=validate and request, |
---|
| 42 | ob=default, |
---|
| 43 | layout_mode='edit', |
---|
| 44 | formaction="searchStudents" |
---|
| 45 | ) |
---|
| 46 | if psm == '': |
---|
| 47 | return context.students_manager_view(rendered = rend, |
---|
| 48 | psm = psm, |
---|
| 49 | #psm = "%s, %s" % (psm,ds), |
---|
| 50 | students = items, |
---|
| 51 | is_manager = is_manager, |
---|
| 52 | ) |
---|
| 53 | what = ds.get('search_mode') |
---|
| 54 | state = ds.get('review_state') |
---|
| 55 | term = ds.get('search_string') |
---|
[572] | 56 | if state == " ----- ": |
---|
| 57 | state = '' |
---|
[589] | 58 | err = False |
---|
[587] | 59 | if not term and what in ('student_edit','jamb_id','name','matric_no'): |
---|
[589] | 60 | psm = "You must specify a search string" |
---|
| 61 | err = True |
---|
| 62 | elif '*' in term: |
---|
| 63 | psm = "You cannot use '*'" |
---|
| 64 | err = True |
---|
| 65 | if err: |
---|
[587] | 66 | return context.students_manager_view(rendered = rend, |
---|
[589] | 67 | psm = psm, |
---|
[587] | 68 | #psm = "%s, %s" % (psm,ds), |
---|
| 69 | students = items, |
---|
| 70 | is_manager = is_manager, |
---|
| 71 | ) |
---|
[584] | 72 | onlyreview = state and what == "review_state" |
---|
[572] | 73 | items = [] |
---|
| 74 | res = [] |
---|
| 75 | portal_type_query = {'query':['Student','StudentApplication','StudentPersonal']} |
---|
[589] | 76 | st_queries = ('jamb_id','matric_no','name') |
---|
[572] | 77 | if onlyreview: |
---|
| 78 | res = catalog(portal_type=portal_type_query, |
---|
| 79 | review_state=state) |
---|
[584] | 80 | elif what == "student_id": |
---|
[572] | 81 | res = catalog(portal_type='Student', |
---|
[587] | 82 | id = term.strip()) |
---|
[589] | 83 | elif what in st_queries: |
---|
| 84 | if what == "jamb_id": |
---|
| 85 | pt = 'StudentApplication' |
---|
| 86 | st = "%s*" % term.strip().lower() |
---|
| 87 | elif what == "matric_no": |
---|
| 88 | pt = 'StudentClearance' |
---|
| 89 | st = "%s*" % term.strip().lower() |
---|
| 90 | elif what == "name": |
---|
| 91 | pt = portal_type_query |
---|
| 92 | st = "%s*" % term.strip() |
---|
| 93 | try: |
---|
| 94 | res = catalog(portal_type=pt,SearchableText=st,) |
---|
| 95 | except: |
---|
| 96 | return context.students_manager_view(rendered = rend, |
---|
| 97 | psm = 'Searchstring "%s" not allowed' % term, |
---|
| 98 | #psm = "%s, %s" % (psm,ds), |
---|
| 99 | students = items, |
---|
| 100 | is_manager = is_manager, |
---|
| 101 | ) |
---|
| 102 | |
---|
[572] | 103 | if res: |
---|
| 104 | for r in res: |
---|
| 105 | if r.portal_type in ("StudentApplication","StudentPersonal"): |
---|
[589] | 106 | student = r.getObject().aq_parent |
---|
[572] | 107 | else: |
---|
[589] | 108 | student = r.getObject() |
---|
| 109 | if student not in items: |
---|
| 110 | items.append(student) |
---|
[584] | 111 | students = [] |
---|
| 112 | if items: |
---|
| 113 | for item in items: |
---|
| 114 | students.append(context.getStudentInfo(item)) |
---|
| 115 | return context.students_manager_view(rendered = rend, |
---|
| 116 | psm = "%d matching Students found" % len(items), |
---|
| 117 | #psm = "%s, %s" % (psm,ds), |
---|
| 118 | students = students, |
---|
| 119 | is_manager = is_manager, |
---|
| 120 | ) |
---|