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