source: WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py @ 971

Last change on this file since 971 was 971, checked in by joachim, 18 years ago

modified pumeresults upload to update results
filename must be pup_update
IMPORTANT the heading must be the same as in the first upload.
Resolved PUME Results contains a different heading.
Import of admitted Students with pictures
students_catalog created
searchStudents speedup

  • Property svn:keywords set to Id
File size: 3.9 KB
Line 
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=student=None
8##title=
9##
10# $Id: getStudentInfo.py 971 2006-11-30 19:31:01Z joachim $
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
22info = {}
23member_id = str(member)
24if student is None:
25    if mtool.isAnonymousUser():
26        return None
27    elif not context.isStudent() and 'students' in path_info:
28        student_id = path_info[path_info.index('students')+1]
29    else:
30        student_id = member_id
31else:
32    student_id = student.getId()
33roles = member.getRoles()
34student_path = "%s/campus/students/%s" % (context.portal_url.getPortalPath(),student_id)
35student = context.restrictedTraverse(student_path,default=None)
36#from Products.zdb import set_trace
37#set_trace()
38
39if student is None or student.portal_type != 'Student':
40    return None
41##res = context.portal_catalog(id = student_id,portal_type='Student')
42##if not res:# or len(res) > 1:
43##    return None
44##brain = res[-1]
45##student = brain.getObject()
46info['review_state'] = wf.getInfoFor(student,'review_state',None)
47info['student'] = student
48info['id'] = student.getId()
49info['url'] = student.absolute_url()
50info['student_doc'] = student.getContent()
51info['app'] = student.application
52info['app_doc'] = student.application.getContent()
53info['per'] = getattr(student,'personal',None)
54info['sex'] = 'male'
55if info['per'] is not None:
56    info['per_doc'] = student.personal.getContent()
57    if info['per_doc'].sex:
58        info['sex'] = 'female'
59else:
60    if info['app_doc'].jamb_sex == "F":
61        info['sex'] = 'female'
62course = getattr(student,'study_course',None)
63info['course'] = course
64if course:
65    info['course_doc'] = student.study_course.getContent()
66#
67acco = getattr(student,'accommodation_2006',None)
68info['acco'] = acco
69if acco is not None:
70    info['acco_doc'] = acco.getContent()
71    info['acco_review_state'] = wf.getInfoFor(acco,'review_state',None)
72#
73clear = getattr(student,'clearance',None)
74info['clear'] = clear
75if clear is not None:
76    info['clear_doc'] = clear.getContent()
77    info['clear_review_state'] = wf.getInfoFor(clear,'review_state',None)
78#
79pume = getattr(student,'pume',None)
80info['pume'] = pume
81if pume is not None:
82    info['pume_doc'] = pume.getContent()
83    info['pume_review_state'] = wf.getInfoFor(pume,'review_state',None)
84else:
85    info['pume'] = None
86
87items = []
88s_edit_links = {'StudentApplication': 'application_edit_form',
89              'StudentAccommodation': 'reserve_accommodation',
90              'StudentClearance': 'clearance_edit_form',
91              'StudentPersonal': '',
92              }
93s_view_links = {'StudentApplication': 'application_view',
94              'StudentAccommodation': 'accommodation_view',
95              'StudentClearance': 'clearance_view',
96              'StudentPersonal': None,
97              'StudentStudyCourse': 'study_course_view',
98              'StudentPume': 'pume_view',
99              }
100sos = context.portal_catalog(container_path=student_path)
101for so in sos:
102    row = {}
103    soo = so.getObject()
104    sod = soo.getContent()
105    row['id'] = soo.getId()
106    row['title'] = sod.Title()
107    row['url'] = soo.absolute_url()
108    row['type'] = so.portal_type
109    row['is_editable'] = mtool.checkPermission('Modify portal content', soo)
110    sv_link = s_view_links.get(so.portal_type,None) or "waeup_document_view"
111    row['s_view_link'] = "%s/%s" % (soo.absolute_url(),sv_link)
112    se_link = s_edit_links.get(so.portal_type,None)
113    row['s_edit_link'] = None
114    if se_link:
115        row['s_edit_link'] = "%s/%s" % (soo.absolute_url(),se_link)
116    row['review_state'] = so.review_state
117    row['display'] = so.review_state in ('opened','closed',)
118    items.append(row)
119info['items'] = items
120request.set('student_id',student_id)
121request.set('student_url',info['url'])
122return info
Note: See TracBrowser for help on using the repository browser.