[1571] | 1 | ## Script (Python) "getStudentFolderInfo" |
---|
[1185] | 2 | ##bind container=container |
---|
| 3 | ##bind context=context |
---|
| 4 | ##bind namespace= |
---|
| 5 | ##bind script=script |
---|
| 6 | ##bind subpath=traverse_subpath |
---|
| 7 | ##parameters=with_items=None |
---|
| 8 | ##title= |
---|
| 9 | ## |
---|
| 10 | # $Id: getStudentFolderInfo.py 3868 2009-01-21 18:20:33Z henrik $ |
---|
| 11 | """ |
---|
| 12 | return Info about the current Student |
---|
[2837] | 13 | try: |
---|
| 14 | from Products.zdb import set_trace |
---|
| 15 | except: |
---|
| 16 | def set_trace(): |
---|
| 17 | pass |
---|
[1185] | 18 | """ |
---|
[2745] | 19 | import DateTime |
---|
[1185] | 20 | request = context.REQUEST |
---|
| 21 | form = request.form |
---|
| 22 | fget = form.get |
---|
| 23 | wf = context.portal_workflow |
---|
| 24 | mtool = context.portal_membership |
---|
| 25 | member = mtool.getAuthenticatedMember() |
---|
| 26 | path_info = request.get('PATH_INFO').split('/') |
---|
| 27 | |
---|
| 28 | import logging |
---|
[1571] | 29 | logger = logging.getLogger('Skins.getStudentFolderInfo') |
---|
[2806] | 30 | from Products.AdvancedQuery import Eq, Between, Le,In |
---|
| 31 | try: |
---|
| 32 | aq_portal = context.portal_catalog.evalAdvancedQuery |
---|
| 33 | except: |
---|
| 34 | aq_portal = context.portal_catalog_real.evalAdvancedQuery |
---|
[1185] | 35 | |
---|
| 36 | |
---|
| 37 | member_id = str(member) |
---|
[3565] | 38 | |
---|
[2975] | 39 | info = context.waeup_tool.getAccessInfo(context) |
---|
| 40 | student_id = info['student_id'] |
---|
| 41 | if student_id is None: |
---|
| 42 | return None |
---|
| 43 | |
---|
[1431] | 44 | student_path_root = "%s/campus/students/%s" % (context.portal_url.getPortalPath(),student_id) |
---|
| 45 | student_path = "%s/campus/students/%s" % (context.portal_url(),student_id) |
---|
[2806] | 46 | students_folder = context.portal_url.getPortalObject().campus.students |
---|
[2961] | 47 | |
---|
[2806] | 48 | student_record = context.students_catalog.getRecordByKey(student_id) |
---|
| 49 | if student_record is None: |
---|
[1185] | 50 | return None |
---|
[2831] | 51 | |
---|
[1185] | 52 | #from Products.zdb import set_trace;set_trace() |
---|
| 53 | for field in context.students_catalog.schema(): |
---|
[2806] | 54 | info[field] = getattr(student_record,field) |
---|
[1359] | 55 | |
---|
[2806] | 56 | #info['review_state'] = context.getStudentReviewState() |
---|
[1871] | 57 | |
---|
[1422] | 58 | info['session'] = False |
---|
[3565] | 59 | if student_record.matric_no and 'uniben' in context.portal_url.getPortalPath(): |
---|
[2806] | 60 | res = context.results_import(matric_no = student_record.matric_no) |
---|
[1422] | 61 | if res: |
---|
| 62 | info['session'] = True |
---|
| 63 | |
---|
[2831] | 64 | info['base_info'] = context.getFormattedStudentEntry(student_record) |
---|
[1472] | 65 | |
---|
[1185] | 66 | info['id'] = student_id |
---|
| 67 | items = [] |
---|
| 68 | s_edit_links = {'StudentApplication': 'application_edit_form', |
---|
| 69 | 'StudentAccommodation': 'reserve_accommodation', |
---|
| 70 | 'StudentClearance': 'clearance_edit_form', |
---|
| 71 | 'StudentPersonal': 'personal_edit_form', |
---|
| 72 | } |
---|
| 73 | s_view_links = {'StudentApplication': 'application_view', |
---|
| 74 | 'StudentAccommodation': 'accommodation_view', |
---|
| 75 | 'StudentClearance': 'clearance_view', |
---|
| 76 | 'StudentPersonal': 'personal_view', |
---|
| 77 | 'StudentStudyCourse': 'study_course_view', |
---|
[1243] | 78 | 'PaymentsFolder': 'payments_view', |
---|
[1185] | 79 | } |
---|
[3473] | 80 | s_view_titles = context.getStudentObjectTitles() |
---|
[2961] | 81 | |
---|
[2806] | 82 | student_obj = getattr(students_folder,student_id) |
---|
| 83 | subobjects = student_obj.objectValues() |
---|
[2961] | 84 | |
---|
[2806] | 85 | for subobject in subobjects: |
---|
[1185] | 86 | row = {} |
---|
[2806] | 87 | row['id'] = subobject.getId() |
---|
[3473] | 88 | if subobject.portal_type == 'StudentAccommodation': |
---|
[3479] | 89 | row['title'] = s_view_titles.get(subobject.portal_type,'') +' for Session %s' %\ |
---|
[3473] | 90 | context.portal_vocabularies.sessions.get(subobject.getContent().session) |
---|
[3666] | 91 | #row['title'] = s_view_titles.get(subobject.portal_type,'') +' %s' %subobject.getContent().session |
---|
[3473] | 92 | else: |
---|
| 93 | row['title'] = s_view_titles.get(subobject.portal_type,'') |
---|
[2806] | 94 | url = row['url'] = subobject.absolute_url() |
---|
| 95 | row['type'] = subobject.portal_type |
---|
| 96 | review_state = row['review_state'] = wf.getInfoFor(subobject,'review_state',None) |
---|
[2975] | 97 | row['is_editable'] = (info['is_student'] and review_state == "opened") or info['is_sectionofficer'] |
---|
[2806] | 98 | sv_link = s_view_links.get(subobject.portal_type,None) or "waeup_document_view" |
---|
[1185] | 99 | row['s_view_link'] = "%s/%s" % (url,sv_link) |
---|
[2806] | 100 | se_link = s_edit_links.get(subobject.portal_type,None) |
---|
[1185] | 101 | row['s_edit_link'] = None |
---|
| 102 | if se_link: |
---|
| 103 | row['s_edit_link'] = "%s/%s" % (url,se_link) |
---|
| 104 | row['display'] = review_state in ('opened','closed','bed_reserved','maintenance_fee_paid',)\ |
---|
[2806] | 105 | and subobject.portal_type not in ('StudentPume','StudentAccommodation','PaymentsFolder',) or\ |
---|
| 106 | subobject.portal_type == 'StudentStudyCourse' |
---|
[1185] | 107 | items.append(row) |
---|
[2961] | 108 | |
---|
[2477] | 109 | items.sort(cmp=lambda x,y: cmp( x['title'],y['title'])) |
---|
[1185] | 110 | info['items'] = items |
---|
[1214] | 111 | info['member'] = member |
---|
[2961] | 112 | |
---|
| 113 | try: |
---|
| 114 | current_level = int(info['level']) |
---|
| 115 | except: |
---|
| 116 | current_level = 0 |
---|
[3868] | 117 | info['transition_return_allowed'] = info['review_state'] in ('school_fee_paid','courses_validated','graduated') and info['is_sectionofficer'] # and current_level > 100 |
---|
[2983] | 118 | info['transition_pay_school_fee_allowed'] = info['review_state'] == 'returning' and info['is_sectionofficer'] |
---|
[3747] | 119 | info['transition_admit_allowed'] = info['review_state'] == 'returning' and info['is_sectionofficer'] |
---|
[2961] | 120 | |
---|
[1185] | 121 | return info |
---|
[1258] | 122 | |
---|