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

Last change on this file since 1389 was 1359, checked in by Henrik Bettermann, 18 years ago

enable hostel booking for school_fee_paid
session result view available only for students with results

  • Property svn:keywords set to Id
File size: 3.4 KB
RevLine 
[1185]1## Script (Python) "getStudentInfo"
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 1359 2007-01-26 09:00:48Z henrik $
11"""
12return Info about the current Student
13"""
14request = context.REQUEST
15form = request.form
16fget = form.get
17wf = context.portal_workflow
18mtool = context.portal_membership
19member = mtool.getAuthenticatedMember()
20path_info = request.get('PATH_INFO').split('/')
21
22import logging
23logger = logging.getLogger('Student.Info')
24
25
26info = {}
27member_id = str(member)
[1243]28#from Products.zdb import set_trace;set_trace()
[1185]29is_student = info['is_student'] = context.isStudent()
30is_staff = info['is_staff'] = context.isStaff()
31is_sectionofficer = info['is_sectionofficer'] = context.isSectionOfficer()
32while True:
33    if mtool.isAnonymousUser():
34        return None
35    requested_id = context.getStudentId()
36    if not is_student and requested_id:
37        student_id = requested_id
38        break
39    if member_id != requested_id:
40        logger.info('"%s", "tried to access", "%s"' % (member_id,requested_id))
41        student_id = member_id
42        mtool.assertViewable(context)
43        break
44    student_id = member_id
45    break
46student_path = "%s/campus/students/%s" % (context.portal_url.getPortalPath(),student_id)
47res = context.students_catalog(id = student_id)
48if not res:
49    return None
50st_brain = res[0]
51#from Products.zdb import set_trace;set_trace()
52for field in context.students_catalog.schema():
53    info[field] = getattr(st_brain,field)
54res = context.portal_catalog(portal_type='Student',id = student_id)
55if res:
56    info['review_state'] = res[0].review_state
[1359]57res = context.results_import(matric_no = st_brain.matric_no)
58if res:
59    info['session'] = True
60else:
61    info['session'] = False
62
[1185]63info['id'] = student_id
64items = []
65s_edit_links = {'StudentApplication': 'application_edit_form',
66              'StudentAccommodation': 'reserve_accommodation',
67              'StudentClearance': 'clearance_edit_form',
68              'StudentPersonal': 'personal_edit_form',
69              }
70s_view_links = {'StudentApplication': 'application_view',
71              'StudentAccommodation': 'accommodation_view',
72              'StudentClearance': 'clearance_view',
73              'StudentPersonal': 'personal_view',
74              'StudentStudyCourse': 'study_course_view',
[1243]75              'PaymentsFolder': 'payments_view',
[1185]76              'StudentPume': 'pume_view',
77              }
78sos = context.portal_catalog(container_path=student_path)
79for so in sos:
80    row = {}
81    row['id'] = so.getId
82    row['title'] = so.Title
83    url = row['url'] = "%s/%s" % (student_path,so.getId)
84    row['type'] = so.portal_type
85    review_state = row['review_state'] = so.review_state
[1214]86    row['is_editable'] = (is_student and review_state == "opened") or not is_student
[1185]87    sv_link = s_view_links.get(so.portal_type,None) or "waeup_document_view"
88    row['s_view_link'] = "%s/%s" % (url,sv_link)
89    se_link = s_edit_links.get(so.portal_type,None)
90    row['s_edit_link'] = None
91    if se_link:
92        row['s_edit_link'] = "%s/%s" % (url,se_link)
93    row['display'] = review_state in ('opened','closed','bed_reserved','maintenance_fee_paid',)\
[1320]94                    and so.portal_type not in  ('StudentPume','StudentAccommodation','PaymentsFolder',) or\
[1185]95                    so.portal_type == 'StudentStudyCourse'
96    items.append(row)
97info['items'] = items
[1214]98info['member'] = member
[1185]99return info
[1258]100
Note: See TracBrowser for help on using the repository browser.