## Script (Python) "getStudyCourseInfo" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=student=None ##title= ## # $Id: getStudyCourseInfo.py 6858 2011-10-04 06:05:39Z henrik $ """ return Info about the Students StudyCourse """ import DateTime from Products.AdvancedQuery import Eq, Between, Le,In mtool = context.portal_membership if mtool.isAnonymousUser(): return None try: from Products.zdb import set_trace except: def set_trace(): pass import logging logger = logging.getLogger('Skins.getStudyCourseInfo') request = context.REQUEST wftool = context.portal_workflow # path_info = request.get('PATH_INFO').split('/') # info = {} info = context.waeup_tool.getAccessInfo(context) student_id = info['student_id'] if student_id is None: return None #info['is_so'] = context.isSectionOfficer() info['is_so'] = info['is_sectionofficer'] info['action'] = "%s" % context.absolute_url() info['choosen_ids'] = request.get('ids',[]) try: course = info['doc'] = context.getContent() except: return None #student_id = context.getStudentId() student_record = context.students_catalog.getRecordByKey(student_id) if not student_record: return None info['student'] = student_record cert_id = student_record.course ci = {} ci['study_course'] = student_record.course ci['faculty'] = student_record.faculty ci['department'] = student_record.department info['course_doc'] = ci items = [] if hasattr(course,'current_verdict'): try: info['verdict'] = context.portal_vocabularies.verdicts.get(course.current_verdict).upper() except: info['verdict'] = course.current_verdict else: info['verdict'] = '' if hasattr(course,'previous_verdict'): try: previous_verdict = course.previous_verdict info['previous_verdict'] = context.portal_vocabularies.verdicts.get(course.previous_verdict).upper() except: info['previous_verdict'] = course.previous_verdict else: info['previous_verdict'] = '' previous_verdict = '' current_level = student_record.level levels = context.objectIds() review_state = wftool.getInfoFor(context,'review_state',None) student_review_state = student_record.review_state has_paid = student_review_state == 'school_fee_paid' may_register = has_paid and\ current_level not in levels and\ (previous_verdict in ('A','B','C','F','J','L','M','N','O','X','Z') or\ current_level in ('000','100') or\ (student_record.entry_mode.startswith('de') and current_level == '200') or\ (student_record.entry_mode.startswith('ph') and current_level == '300') or\ (student_record.entry_mode.startswith('pd') and current_level == '500')) #fceokene only info['may_register_501'] = (current_level == '500') and '501' not in levels missing_data = has_paid and\ current_level not in levels and\ not (previous_verdict or student_record.level) and\ not (current_level == '100' or\ (student_record.entry_mode.startswith('de') and current_level == '200') or\ (student_record.entry_mode.startswith('ph') and current_level == '300') or\ (student_record.entry_mode.startswith('pd') and current_level == '500')) #fceokene only info['missing_data'] = missing_data levels.sort() info['create_level'] = None student_levels_voc = context.portal_vocabularies.student_levels if may_register: info['create_level'] = current_level info['create_level_str'] = student_levels_voc.get(current_level) for l in levels: row = {} row['id'] = l #row['title'] = "Level %s" % l row['title'] = student_levels_voc.get(l) row['url'] = "%s/%s" % (context.absolute_url(),l) items.append(row) info['items'] = items return info