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