source: WAeUP_SRP/trunk/skins/waeup_student/getStudentFolderInfo.py @ 16045

Last change on this file since 16045 was 5620, checked in by Henrik Bettermann, 14 years ago

final step

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