[845] | 1 | ## Script (Python) "getStudyCourseInfo" |
---|
[723] | 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 | ## |
---|
[805] | 10 | # $Id: getStudyCourseInfo.py 1816 2007-05-24 05:49:27Z henrik $ |
---|
[723] | 11 | """ |
---|
| 12 | return Info about the Students StudyCourse |
---|
| 13 | """ |
---|
[1783] | 14 | |
---|
| 15 | mtool = context.portal_membership |
---|
| 16 | if mtool.isAnonymousUser(): |
---|
| 17 | return None |
---|
| 18 | |
---|
[1494] | 19 | try: |
---|
| 20 | from Products.zdb import set_trace |
---|
| 21 | except: |
---|
| 22 | def set_trace(): |
---|
| 23 | pass |
---|
| 24 | |
---|
[723] | 25 | request = context.REQUEST |
---|
| 26 | |
---|
[1490] | 27 | wftool = context.portal_workflow |
---|
[723] | 28 | path_info = request.get('PATH_INFO').split('/') |
---|
| 29 | |
---|
| 30 | info = {} |
---|
[1380] | 31 | info['is_so'] = context.isSectionOfficer() |
---|
[1650] | 32 | info['action'] = "%s" % context.absolute_url() |
---|
[723] | 33 | info['choosen_ids'] = request.get('ids',[]) |
---|
[1380] | 34 | course = info['doc'] = context.getContent() |
---|
| 35 | student_id = context.getStudentId() |
---|
| 36 | res = context.students_catalog(id = student_id) |
---|
| 37 | if not res: |
---|
| 38 | return None |
---|
| 39 | sbrain = res[0] |
---|
[1403] | 40 | info['student'] = sbrain |
---|
[1380] | 41 | cert_id = sbrain.course |
---|
| 42 | res = context.portal_catalog(portal_type = "Certificate", id = cert_id) |
---|
| 43 | ci = {} |
---|
| 44 | if res: |
---|
| 45 | info['cert_id'] = cert_id |
---|
| 46 | brain = res[0] |
---|
| 47 | ci['study_course'] = brain.getId |
---|
| 48 | ci['title'] = brain.Title |
---|
| 49 | pl = brain.getPath().split('/') |
---|
| 50 | ci['faculty'] = pl[-4] |
---|
| 51 | ci['department'] = pl[-3] |
---|
| 52 | info['course_doc'] = ci |
---|
| 53 | else: |
---|
[1816] | 54 | info['cert_id'] = 'N/A' |
---|
| 55 | ci['study_course'] = 'N/A' |
---|
| 56 | ci['title'] = 'N/A' |
---|
| 57 | ci['faculty'] = 'N/A' |
---|
| 58 | ci['department'] = 'N/A' |
---|
| 59 | info['course_doc'] = ci |
---|
| 60 | |
---|
[723] | 61 | items = [] |
---|
[1492] | 62 | current_level = sbrain.level |
---|
| 63 | levels = context.objectIds() |
---|
| 64 | review_state = wftool.getInfoFor(context,'review_state',None) |
---|
[1565] | 65 | student_review_state = context.getStudentReviewState() |
---|
[1571] | 66 | if review_state != 'content_addable' and student_review_state == 'school_fee_paid': #and context.isStudent(): |
---|
[1492] | 67 | wftool.doActionFor(context,'close_for_edit') |
---|
[1500] | 68 | may_register = (student_review_state in ('school_fee_paid',)) and\ |
---|
[1537] | 69 | current_level not in levels and\ |
---|
[1695] | 70 | (sbrain.verdict in ('A','B','C','J') or sbrain.jamb_reg_no.startswith('6')) |
---|
[1565] | 71 | |
---|
[1492] | 72 | levels.sort() |
---|
| 73 | info['create_level'] = None |
---|
| 74 | if may_register: |
---|
| 75 | info['create_level'] = current_level |
---|
| 76 | for l in levels: |
---|
| 77 | row = {} |
---|
| 78 | row['id'] = l |
---|
| 79 | row['title'] = "Level %s" % l |
---|
| 80 | row['url'] = "%s/%s" % (context.absolute_url(),l) |
---|
| 81 | items.append(row) |
---|
[1380] | 82 | |
---|
[723] | 83 | info['items'] = items |
---|
[1504] | 84 | |
---|
[1565] | 85 | try: |
---|
[1504] | 86 | info['verdict'] = context.portal_vocabularies.verdicts.get(info['doc'].current_verdict).upper() |
---|
| 87 | except: |
---|
[1565] | 88 | info['verdict'] = course.current_verdict |
---|
[1504] | 89 | |
---|
[723] | 90 | return info |
---|
[1504] | 91 | |
---|