[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 4557 2009-12-12 04:25:28Z 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 |
---|
| 54 | # logger.info("before search") |
---|
| 55 | # starttime = DateTime.DateTime().timeTime() |
---|
| 56 | # res = context.portal_catalog_real.evalAdvancedQuery(Eq('id', cert_id)) # & |
---|
| 57 | # Eq('portal_type', "Certificate")) |
---|
| 58 | # logger.info("searchtime %f" % (DateTime.DateTime().timeTime() - starttime)) |
---|
| 59 | # if True: |
---|
| 60 | # #info['cert_id'] = cert_id |
---|
| 61 | # # brain = res[0] |
---|
| 62 | # # ci['title'] = brain.Title |
---|
| 63 | # # pl = brain.getPath().split('/') |
---|
| 64 | # # ci['faculty'] = pl[-4] |
---|
| 65 | # # ci['department'] = pl[-3] |
---|
| 66 | # ci['study_course'] = student_record.course |
---|
| 67 | # ci['faculty'] = student_record.faculty |
---|
| 68 | # ci['department'] = student_record.department |
---|
| 69 | # info['course_doc'] = ci |
---|
| 70 | # else: |
---|
| 71 | # info['cert_id'] = 'N/A' |
---|
| 72 | # ci['study_course'] = 'N/A' |
---|
| 73 | # ci['title'] = 'N/A' |
---|
| 74 | # ci['faculty'] = 'N/A' |
---|
| 75 | # ci['department'] = 'N/A' |
---|
| 76 | # info['course_doc'] = ci |
---|
[1380] | 77 | ci = {} |
---|
[2876] | 78 | ci['study_course'] = student_record.course |
---|
| 79 | ci['faculty'] = student_record.faculty |
---|
| 80 | ci['department'] = student_record.department |
---|
| 81 | info['course_doc'] = ci |
---|
[2010] | 82 | |
---|
[723] | 83 | items = [] |
---|
[2483] | 84 | |
---|
| 85 | if hasattr(course,'current_verdict'): |
---|
| 86 | try: |
---|
| 87 | info['verdict'] = context.portal_vocabularies.verdicts.get(course.current_verdict).upper() |
---|
| 88 | except: |
---|
| 89 | info['verdict'] = course.current_verdict |
---|
| 90 | else: |
---|
| 91 | info['verdict'] = '' |
---|
| 92 | |
---|
| 93 | if hasattr(course,'previous_verdict'): |
---|
| 94 | try: |
---|
| 95 | previous_verdict = course.previous_verdict |
---|
| 96 | info['previous_verdict'] = context.portal_vocabularies.verdicts.get(course.previous_verdict).upper() |
---|
| 97 | except: |
---|
| 98 | info['previous_verdict'] = course.previous_verdict |
---|
| 99 | else: |
---|
| 100 | info['previous_verdict'] = '' |
---|
| 101 | previous_verdict = '' |
---|
| 102 | |
---|
| 103 | |
---|
[2876] | 104 | current_level = student_record.level |
---|
[1492] | 105 | levels = context.objectIds() |
---|
| 106 | review_state = wftool.getInfoFor(context,'review_state',None) |
---|
[2876] | 107 | student_review_state = student_record.review_state |
---|
[2752] | 108 | #if review_state != 'content_addable' and student_review_state == 'school_fee_paid': #and context.isStudent(): |
---|
| 109 | # wftool.doActionFor(context,'close_for_edit') |
---|
[2674] | 110 | |
---|
[2664] | 111 | has_paid = student_review_state == 'school_fee_paid' |
---|
| 112 | |
---|
| 113 | may_register = has_paid and\ |
---|
| 114 | current_level not in levels and\ |
---|
[4557] | 115 | (previous_verdict in ('A','B','C','F','J','L','M','N','Z') or\ |
---|
[3072] | 116 | current_level in ('000','100') or\ |
---|
[3803] | 117 | (student_record.entry_mode.startswith('de') and current_level == '200') or\ |
---|
| 118 | (student_record.entry_mode.startswith('ph') and current_level == '300')) |
---|
[2678] | 119 | |
---|
[2674] | 120 | missing_data = has_paid and\ |
---|
| 121 | current_level not in levels and\ |
---|
[2876] | 122 | not (previous_verdict or student_record.level) and\ |
---|
[2674] | 123 | not (current_level == '100' or\ |
---|
[3803] | 124 | (student_record.entry_mode.startswith('de') and current_level == '200')or\ |
---|
| 125 | (student_record.entry_mode.startswith('ph') and current_level == '300')) |
---|
[2664] | 126 | |
---|
[2674] | 127 | info['missing_data'] = missing_data |
---|
[1492] | 128 | levels.sort() |
---|
| 129 | info['create_level'] = None |
---|
[2640] | 130 | student_levels_voc = context.portal_vocabularies.student_levels |
---|
[2678] | 131 | if may_register: |
---|
[1492] | 132 | info['create_level'] = current_level |
---|
[2640] | 133 | info['create_level_str'] = student_levels_voc.get(current_level) |
---|
[1492] | 134 | for l in levels: |
---|
| 135 | row = {} |
---|
| 136 | row['id'] = l |
---|
[2640] | 137 | #row['title'] = "Level %s" % l |
---|
| 138 | row['title'] = student_levels_voc.get(l) |
---|
[1492] | 139 | row['url'] = "%s/%s" % (context.absolute_url(),l) |
---|
| 140 | items.append(row) |
---|
[1380] | 141 | |
---|
[723] | 142 | info['items'] = items |
---|
[1504] | 143 | |
---|
[2483] | 144 | |
---|
| 145 | |
---|
[723] | 146 | return info |
---|
[1504] | 147 | |
---|