source: WAeUP_SRP/base/skins/waeup_student/getStudentFolderInfo.py @ 2961

Last change on this file since 2961 was 2961, checked in by Henrik Bettermann, 17 years ago

install button to execute transitions return and pay_school_fee

  • Property svn:keywords set to Id
File size: 4.3 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 2961 2007-12-19 11:16:49Z 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
31try:
32    aq_portal = context.portal_catalog.evalAdvancedQuery
33except:
34    aq_portal = context.portal_catalog_real.evalAdvancedQuery
[1185]35
36
37info = {}
38member_id = str(member)
[1243]39#from Products.zdb import set_trace;set_trace()
[1185]40is_student = info['is_student'] = context.isStudent()
41is_staff = info['is_staff'] = context.isStaff()
42is_sectionofficer = info['is_sectionofficer'] = context.isSectionOfficer()
43while True:
44    if mtool.isAnonymousUser():
45        return None
46    requested_id = context.getStudentId()
47    if not is_student and requested_id:
48        student_id = requested_id
49        break
50    if member_id != requested_id:
[1571]51        logger.info('%s tried to access %s' % (member_id,requested_id))
[1185]52        student_id = member_id
53        mtool.assertViewable(context)
54        break
55    student_id = member_id
56    break
[1431]57student_path_root = "%s/campus/students/%s" % (context.portal_url.getPortalPath(),student_id)
58student_path = "%s/campus/students/%s" % (context.portal_url(),student_id)
[2806]59students_folder = context.portal_url.getPortalObject().campus.students
[2961]60
[2806]61student_record = context.students_catalog.getRecordByKey(student_id)
62if student_record is None:
[1185]63    return None
[2831]64
[1185]65#from Products.zdb import set_trace;set_trace()
66for field in context.students_catalog.schema():
[2806]67    info[field] = getattr(student_record,field)
[1359]68
[2806]69#info['review_state'] = context.getStudentReviewState()
[1871]70
[1422]71info['session'] = False
[2806]72if student_record.matric_no:
73    res = context.results_import(matric_no = student_record.matric_no)
[1422]74    if res:
75       info['session'] = True
76
[2831]77info['base_info'] = context.getFormattedStudentEntry(student_record)
[1472]78
[1185]79info['id'] = student_id
80items = []
81s_edit_links = {'StudentApplication': 'application_edit_form',
82              'StudentAccommodation': 'reserve_accommodation',
83              'StudentClearance': 'clearance_edit_form',
84              'StudentPersonal': 'personal_edit_form',
85              }
86s_view_links = {'StudentApplication': 'application_view',
87              'StudentAccommodation': 'accommodation_view',
88              'StudentClearance': 'clearance_view',
89              'StudentPersonal': 'personal_view',
90              'StudentStudyCourse': 'study_course_view',
[1243]91              'PaymentsFolder': 'payments_view',
[1185]92              }
[2961]93
[2806]94student_obj = getattr(students_folder,student_id)
95subobjects = student_obj.objectValues()
[2961]96
[2806]97for subobject in subobjects:
[1185]98    row = {}
[2806]99    row['id'] = subobject.getId()
[2837]100    row['title'] = subobject.Title()
[2806]101    url = row['url'] = subobject.absolute_url()
102    row['type'] = subobject.portal_type
103    review_state = row['review_state'] = wf.getInfoFor(subobject,'review_state',None)
[1472]104    row['is_editable'] = (is_student and review_state == "opened") or is_sectionofficer
[2806]105    sv_link = s_view_links.get(subobject.portal_type,None) or "waeup_document_view"
[1185]106    row['s_view_link'] = "%s/%s" % (url,sv_link)
[2806]107    se_link = s_edit_links.get(subobject.portal_type,None)
[1185]108    row['s_edit_link'] = None
109    if se_link:
110        row['s_edit_link'] = "%s/%s" % (url,se_link)
111    row['display'] = review_state in ('opened','closed','bed_reserved','maintenance_fee_paid',)\
[2806]112                    and subobject.portal_type not in  ('StudentPume','StudentAccommodation','PaymentsFolder',) or\
113                    subobject.portal_type == 'StudentStudyCourse'
[1185]114    items.append(row)
[2961]115
[2477]116items.sort(cmp=lambda x,y: cmp( x['title'],y['title']))
[1185]117info['items'] = items
[1214]118info['member'] = member
[2961]119
120try:
121    current_level = int(info['level'])
122except:
123    current_level = 0
124info['transition_return_allowed'] = info['review_state'] == 'school_fee_paid' and current_level > 100 and is_sectionofficer
125info['transition_pay_school_fee_allowed'] = info['review_state'] == 'returning' and is_sectionofficer
126
[1185]127return info
[1258]128
Note: See TracBrowser for help on using the repository browser.