## Script (Python) "getStudentFolderInfo" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=with_items=None ##title= ## # $Id: getStudentFolderInfo.py 5161 2010-04-20 14:44:54Z henrik $ """ return Info about the current Student try: from Products.zdb import set_trace except: def set_trace(): pass """ import DateTime request = context.REQUEST form = request.form fget = form.get wf = context.portal_workflow mtool = context.portal_membership member = mtool.getAuthenticatedMember() path_info = request.get('PATH_INFO').split('/') import logging logger = logging.getLogger('Skins.getStudentFolderInfo') from Products.AdvancedQuery import Eq, Between, Le,In member_id = str(member) info = context.waeup_tool.getAccessInfo(context) student_id = info['student_id'] if student_id is None: return None student_path_root = "%s/campus/students/%s" % (context.portal_url.getPortalPath(),student_id) student_path = "%s/campus/students/%s" % (context.portal_url(),student_id) students_folder = context.portal_url.getPortalObject().campus.students student_record = context.students_catalog.getRecordByKey(student_id) if student_record is None: return None #from Products.zdb import set_trace;set_trace() for field in context.students_catalog.schema(): info[field] = getattr(student_record,field) #info['review_state'] = context.getStudentReviewState() info['session'] = False if student_record.matric_no and 'uniben' in context.portal_url.getPortalPath(): res = context.results_import(matric_no = student_record.matric_no) if res: info['session'] = True info['base_info'] = context.getFormattedStudentEntry(student_record) info['id'] = student_id items = [] s_edit_links = {'StudentApplication': 'application_edit_form', 'StudentAccommodation': 'reserve_accommodation', 'StudentClearance': 'clearance_edit_form', 'StudentPersonal': 'personal_edit_form', } s_view_links = {'StudentApplication': 'application_view', 'StudentAccommodation': 'accommodation_view', 'StudentClearance': 'clearance_view', 'StudentPersonal': 'personal_view', 'StudentStudyCourse': 'study_course_view', 'PaymentsFolder': 'payments_view', } s_view_titles = context.getStudentObjectTitles() student_obj = getattr(students_folder,student_id) subobjects = student_obj.objectValues() for subobject in subobjects: row = {} row['id'] = subobject.getId() if subobject.portal_type == 'StudentAccommodation': row['title'] = s_view_titles.get(subobject.portal_type,'') +' for Session %s' %\ context.portal_vocabularies.sessions.get(subobject.getContent().session) #row['title'] = s_view_titles.get(subobject.portal_type,'') +' %s' %subobject.getContent().session else: row['title'] = s_view_titles.get(subobject.portal_type,'') url = row['url'] = subobject.absolute_url() row['type'] = subobject.portal_type review_state = row['review_state'] = wf.getInfoFor(subobject,'review_state',None) row['is_editable'] = (info['is_student'] and review_state == "opened") or info['is_sectionofficer'] sv_link = s_view_links.get(subobject.portal_type,None) or "waeup_document_view" row['s_view_link'] = "%s/%s" % (url,sv_link) se_link = s_edit_links.get(subobject.portal_type,None) row['s_edit_link'] = None if se_link: row['s_edit_link'] = "%s/%s" % (url,se_link) row['display'] = review_state in ('opened','closed','bed_reserved','maintenance_fee_paid',)\ and subobject.portal_type not in ('StudentPume','StudentAccommodation','PaymentsFolder',) or\ subobject.portal_type == 'StudentStudyCourse' items.append(row) items.sort(cmp=lambda x,y: cmp( x['title'],y['title'])) info['items'] = items info['member'] = member try: current_level = int(info['level']) except: current_level = 0 info['transition_return_allowed'] = info['review_state'] in ('school_fee_paid','courses_validated','graduated') and info['is_sectionofficer'] # and current_level > 100 info['transition_pay_school_fee_allowed'] = info['review_state'] == 'returning' and info['is_sectionofficer'] info['transition_admit_allowed'] = info['review_state'] == 'returning' and info['is_sectionofficer'] return info