[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 2752 2007-11-24 06:06:14Z 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 |
---|
[2010] | 60 | |
---|
[723] | 61 | items = [] |
---|
[2483] | 62 | |
---|
| 63 | if hasattr(course,'current_verdict'): |
---|
| 64 | try: |
---|
| 65 | info['verdict'] = context.portal_vocabularies.verdicts.get(course.current_verdict).upper() |
---|
| 66 | except: |
---|
| 67 | info['verdict'] = course.current_verdict |
---|
| 68 | else: |
---|
| 69 | info['verdict'] = '' |
---|
| 70 | |
---|
| 71 | if hasattr(course,'previous_verdict'): |
---|
| 72 | try: |
---|
| 73 | previous_verdict = course.previous_verdict |
---|
| 74 | info['previous_verdict'] = context.portal_vocabularies.verdicts.get(course.previous_verdict).upper() |
---|
| 75 | except: |
---|
| 76 | info['previous_verdict'] = course.previous_verdict |
---|
| 77 | else: |
---|
| 78 | info['previous_verdict'] = '' |
---|
| 79 | previous_verdict = '' |
---|
| 80 | |
---|
| 81 | |
---|
[1492] | 82 | current_level = sbrain.level |
---|
| 83 | levels = context.objectIds() |
---|
| 84 | review_state = wftool.getInfoFor(context,'review_state',None) |
---|
[2664] | 85 | student_review_state = sbrain.review_state |
---|
[2752] | 86 | #if review_state != 'content_addable' and student_review_state == 'school_fee_paid': #and context.isStudent(): |
---|
| 87 | # wftool.doActionFor(context,'close_for_edit') |
---|
[2674] | 88 | |
---|
[2664] | 89 | has_paid = student_review_state == 'school_fee_paid' |
---|
| 90 | |
---|
| 91 | may_register = has_paid and\ |
---|
| 92 | current_level not in levels and\ |
---|
| 93 | (previous_verdict in ('A','B','C','F','J','L','M') or\ |
---|
[2674] | 94 | current_level == '100' or\ |
---|
| 95 | (sbrain.mode.startswith('de') and current_level == '200')) |
---|
[2678] | 96 | |
---|
[2674] | 97 | missing_data = has_paid and\ |
---|
| 98 | current_level not in levels and\ |
---|
| 99 | not (previous_verdict or sbrain.level) and\ |
---|
| 100 | not (current_level == '100' or\ |
---|
[2678] | 101 | (sbrain.mode.startswith('de') and current_level == '200')) |
---|
[2664] | 102 | |
---|
[2674] | 103 | info['missing_data'] = missing_data |
---|
[1492] | 104 | levels.sort() |
---|
| 105 | info['create_level'] = None |
---|
[2640] | 106 | student_levels_voc = context.portal_vocabularies.student_levels |
---|
[2678] | 107 | if may_register: |
---|
[1492] | 108 | info['create_level'] = current_level |
---|
[2640] | 109 | info['create_level_str'] = student_levels_voc.get(current_level) |
---|
[1492] | 110 | for l in levels: |
---|
| 111 | row = {} |
---|
| 112 | row['id'] = l |
---|
[2640] | 113 | #row['title'] = "Level %s" % l |
---|
| 114 | row['title'] = student_levels_voc.get(l) |
---|
[1492] | 115 | row['url'] = "%s/%s" % (context.absolute_url(),l) |
---|
| 116 | items.append(row) |
---|
[1380] | 117 | |
---|
[723] | 118 | info['items'] = items |
---|
[1504] | 119 | |
---|
[2483] | 120 | |
---|
| 121 | |
---|
[723] | 122 | return info |
---|
[1504] | 123 | |
---|