[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 |
---|
| 7 | ##parameters=student=None |
---|
| 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 |
---|
[572] | 17 | info = {} |
---|
[565] | 18 | wf = context.portal_workflow |
---|
[572] | 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 | |
---|
[565] | 24 | mtool = context.portal_membership |
---|
| 25 | member = mtool.getAuthenticatedMember() |
---|
| 26 | path_info = request.get('PATH_INFO').split('/') |
---|
| 27 | roles = member.getRoles() |
---|
| 28 | info['is_manager'] = 'Manager' in roles or 'SectionManager' in roles |
---|
| 29 | student_id = fget('student_id') |
---|
| 30 | jamb_id = fget('jamb_id') |
---|
| 31 | matric_no = fget('matric_no') |
---|
| 32 | name = fget('name') |
---|
[572] | 33 | state = fget('state') |
---|
| 34 | if state == " ----- ": |
---|
| 35 | state = '' |
---|
| 36 | onlyreview = state and not (student_id or jamb_id or matric_no or name) |
---|
| 37 | items = [] |
---|
| 38 | res = [] |
---|
| 39 | portal_type_query = {'query':['Student','StudentApplication','StudentPersonal']} |
---|
| 40 | if onlyreview: |
---|
| 41 | res = catalog(portal_type=portal_type_query, |
---|
| 42 | review_state=state) |
---|
| 43 | elif student_id: |
---|
| 44 | res = catalog(portal_type='Student', |
---|
| 45 | id = student_id.strip()) |
---|
| 46 | elif jamb_id: |
---|
| 47 | res = catalog(portal_type='StudentApplication', |
---|
| 48 | SearchableText="%s*" % jamb_id.strip().lower()) |
---|
| 49 | elif matric_no: |
---|
| 50 | res = catalog(portal_type='StudentClearance', |
---|
| 51 | SearchableText="%s*" % matric_no.strip().lower()) |
---|
| 52 | elif name: |
---|
| 53 | res = catalog(portal_type=portal_type_query, |
---|
| 54 | SearchableText="%s*" % name.strip()) |
---|
| 55 | if res: |
---|
| 56 | for r in res: |
---|
| 57 | row = {} |
---|
| 58 | if r.portal_type in ("StudentApplication","StudentPersonal"): |
---|
| 59 | items.append(r.getObject().aq_parent) |
---|
| 60 | else: |
---|
| 61 | items.append(r.getObject()) |
---|
| 62 | info['state'] = state |
---|
| 63 | info['student_id'] = student_id |
---|
| 64 | info['jamb_id'] = jamb_id |
---|
| 65 | info['matric_no'] = matric_no |
---|
| 66 | info['name'] = name |
---|
| 67 | |
---|
| 68 | info['students'] = items |
---|
[565] | 69 | return info |
---|