[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 2855 2007-12-04 15:47:06Z joachim $ |
---|
[723] | 11 | """ |
---|
| 12 | return Info about the Students StudyCourse |
---|
| 13 | """ |
---|
[2855] | 14 | from Products.AdvancedQuery import Eq, Between, Le,In |
---|
[1783] | 15 | |
---|
| 16 | mtool = context.portal_membership |
---|
| 17 | if mtool.isAnonymousUser(): |
---|
| 18 | return None |
---|
| 19 | |
---|
[1494] | 20 | try: |
---|
| 21 | from Products.zdb import set_trace |
---|
| 22 | except: |
---|
| 23 | def set_trace(): |
---|
| 24 | pass |
---|
| 25 | |
---|
[723] | 26 | request = context.REQUEST |
---|
| 27 | |
---|
[1490] | 28 | wftool = context.portal_workflow |
---|
[723] | 29 | path_info = request.get('PATH_INFO').split('/') |
---|
| 30 | |
---|
| 31 | info = {} |
---|
[1380] | 32 | info['is_so'] = context.isSectionOfficer() |
---|
[1650] | 33 | info['action'] = "%s" % context.absolute_url() |
---|
[723] | 34 | info['choosen_ids'] = request.get('ids',[]) |
---|
[1380] | 35 | course = info['doc'] = context.getContent() |
---|
| 36 | student_id = context.getStudentId() |
---|
| 37 | res = context.students_catalog(id = student_id) |
---|
| 38 | if not res: |
---|
| 39 | return None |
---|
| 40 | sbrain = res[0] |
---|
[1403] | 41 | info['student'] = sbrain |
---|
[1380] | 42 | cert_id = sbrain.course |
---|
[2855] | 43 | res = context.portal_catalog_real.evalAdvancedQuery(Eq('id', cert_id) & |
---|
| 44 | Eq('portal_type', "Certificate")) |
---|
[1380] | 45 | ci = {} |
---|
| 46 | if res: |
---|
| 47 | info['cert_id'] = cert_id |
---|
| 48 | brain = res[0] |
---|
| 49 | ci['study_course'] = brain.getId |
---|
| 50 | ci['title'] = brain.Title |
---|
| 51 | pl = brain.getPath().split('/') |
---|
| 52 | ci['faculty'] = pl[-4] |
---|
| 53 | ci['department'] = pl[-3] |
---|
| 54 | info['course_doc'] = ci |
---|
| 55 | else: |
---|
[1816] | 56 | info['cert_id'] = 'N/A' |
---|
| 57 | ci['study_course'] = 'N/A' |
---|
| 58 | ci['title'] = 'N/A' |
---|
| 59 | ci['faculty'] = 'N/A' |
---|
| 60 | ci['department'] = 'N/A' |
---|
| 61 | info['course_doc'] = ci |
---|
[2010] | 62 | |
---|
[723] | 63 | items = [] |
---|
[2483] | 64 | |
---|
| 65 | if hasattr(course,'current_verdict'): |
---|
| 66 | try: |
---|
| 67 | info['verdict'] = context.portal_vocabularies.verdicts.get(course.current_verdict).upper() |
---|
| 68 | except: |
---|
| 69 | info['verdict'] = course.current_verdict |
---|
| 70 | else: |
---|
| 71 | info['verdict'] = '' |
---|
| 72 | |
---|
| 73 | if hasattr(course,'previous_verdict'): |
---|
| 74 | try: |
---|
| 75 | previous_verdict = course.previous_verdict |
---|
| 76 | info['previous_verdict'] = context.portal_vocabularies.verdicts.get(course.previous_verdict).upper() |
---|
| 77 | except: |
---|
| 78 | info['previous_verdict'] = course.previous_verdict |
---|
| 79 | else: |
---|
| 80 | info['previous_verdict'] = '' |
---|
| 81 | previous_verdict = '' |
---|
| 82 | |
---|
| 83 | |
---|
[1492] | 84 | current_level = sbrain.level |
---|
| 85 | levels = context.objectIds() |
---|
| 86 | review_state = wftool.getInfoFor(context,'review_state',None) |
---|
[2664] | 87 | student_review_state = sbrain.review_state |
---|
[2752] | 88 | #if review_state != 'content_addable' and student_review_state == 'school_fee_paid': #and context.isStudent(): |
---|
| 89 | # wftool.doActionFor(context,'close_for_edit') |
---|
[2674] | 90 | |
---|
[2664] | 91 | has_paid = student_review_state == 'school_fee_paid' |
---|
| 92 | |
---|
| 93 | may_register = has_paid and\ |
---|
| 94 | current_level not in levels and\ |
---|
| 95 | (previous_verdict in ('A','B','C','F','J','L','M') or\ |
---|
[2674] | 96 | current_level == '100' or\ |
---|
| 97 | (sbrain.mode.startswith('de') and current_level == '200')) |
---|
[2678] | 98 | |
---|
[2674] | 99 | missing_data = has_paid and\ |
---|
| 100 | current_level not in levels and\ |
---|
| 101 | not (previous_verdict or sbrain.level) and\ |
---|
| 102 | not (current_level == '100' or\ |
---|
[2678] | 103 | (sbrain.mode.startswith('de') and current_level == '200')) |
---|
[2664] | 104 | |
---|
[2674] | 105 | info['missing_data'] = missing_data |
---|
[1492] | 106 | levels.sort() |
---|
| 107 | info['create_level'] = None |
---|
[2640] | 108 | student_levels_voc = context.portal_vocabularies.student_levels |
---|
[2678] | 109 | if may_register: |
---|
[1492] | 110 | info['create_level'] = current_level |
---|
[2640] | 111 | info['create_level_str'] = student_levels_voc.get(current_level) |
---|
[1492] | 112 | for l in levels: |
---|
| 113 | row = {} |
---|
| 114 | row['id'] = l |
---|
[2640] | 115 | #row['title'] = "Level %s" % l |
---|
| 116 | row['title'] = student_levels_voc.get(l) |
---|
[1492] | 117 | row['url'] = "%s/%s" % (context.absolute_url(),l) |
---|
| 118 | items.append(row) |
---|
[1380] | 119 | |
---|
[723] | 120 | info['items'] = items |
---|
[1504] | 121 | |
---|
[2483] | 122 | |
---|
| 123 | |
---|
[723] | 124 | return info |
---|
[1504] | 125 | |
---|