## 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 2678 2007-11-16 13:41:44Z henrik $ """ return Info about the Students StudyCourse """ mtool = context.portal_membership if mtool.isAnonymousUser(): return None try: from Products.zdb import set_trace except: def set_trace(): pass request = context.REQUEST wftool = context.portal_workflow path_info = request.get('PATH_INFO').split('/') info = {} info['is_so'] = context.isSectionOfficer() info['action'] = "%s" % context.absolute_url() info['choosen_ids'] = request.get('ids',[]) course = info['doc'] = context.getContent() student_id = context.getStudentId() res = context.students_catalog(id = student_id) if not res: return None sbrain = res[0] info['student'] = sbrain cert_id = sbrain.course res = context.portal_catalog(portal_type = "Certificate", id = cert_id) ci = {} if res: info['cert_id'] = cert_id brain = res[0] ci['study_course'] = brain.getId ci['title'] = brain.Title pl = brain.getPath().split('/') ci['faculty'] = pl[-4] ci['department'] = pl[-3] info['course_doc'] = ci else: info['cert_id'] = 'N/A' ci['study_course'] = 'N/A' ci['title'] = 'N/A' ci['faculty'] = 'N/A' ci['department'] = 'N/A' 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 = sbrain.level levels = context.objectIds() review_state = wftool.getInfoFor(context,'review_state',None) student_review_state = sbrain.review_state if review_state != 'content_addable' and student_review_state == 'school_fee_paid': #and context.isStudent(): wftool.doActionFor(context,'close_for_edit') 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') or\ current_level == '100' or\ (sbrain.mode.startswith('de') and current_level == '200')) missing_data = has_paid and\ current_level not in levels and\ not (previous_verdict or sbrain.level) and\ not (current_level == '100' or\ (sbrain.mode.startswith('de') and current_level == '200')) 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