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

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

created new catalog pumeresults for pumeresult checking
modified pume_anon_view and pume_anon_slip to use it.

  • 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 966 2006-11-29 14:26:31Z 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)
36if student is None or student.portal_type != 'Student':
37    return None
38##res = context.portal_catalog(id = student_id,portal_type='Student')
39##if not res:# or len(res) > 1:
40##    return None
41##brain = res[-1]
42##student = brain.getObject()
43info['review_state'] = wf.getInfoFor(student,'review_state',None)
44info['student'] = student
45info['id'] = student.getId()
46info['url'] = student.absolute_url()
47info['student_doc'] = student.getContent()
48info['app'] = student.application
49info['app_doc'] = student.application.getContent()
50info['per'] = getattr(student,'personal',None)
51info['sex'] = 'male'
52if info['per'] is not None:
53    info['per_doc'] = student.personal.getContent()
54    if info['per_doc'].sex:
55        info['sex'] = 'female'
56else:
57    if info['app_doc'].jamb_sex == "F":
58        info['sex'] = 'female'
59course = getattr(student,'study_course',None)
60info['course'] = course
61if course:
62    info['course_doc'] = student.study_course.getContent()
63#
64acco = getattr(student,'accommodation_2006',None)
65info['acco'] = acco
66if acco is not None:
67    info['acco_doc'] = acco.getContent()
68    info['acco_review_state'] = wf.getInfoFor(acco,'review_state',None)
69#
70clear = getattr(student,'clearance',None)
71info['clear'] = clear
72if clear is not None:
73    info['clear_doc'] = clear.getContent()
74    info['clear_review_state'] = wf.getInfoFor(clear,'review_state',None)
75#
76pume = getattr(student,'pume',None)
77info['pume'] = pume
78if pume is not None:
79    info['pume_doc'] = pume.getContent()
80    info['pume_review_state'] = wf.getInfoFor(pume,'review_state',None)
81else:
82    info['pume'] = None
83
84items = []
85s_edit_links = {'StudentApplication': 'application_edit_form',
86              'StudentAccommodation': 'reserve_accommodation',
87              'StudentClearance': 'clearance_edit_form',
88              'StudentPersonal': '',
89              }
90s_view_links = {'StudentApplication': 'application_view',
91              'StudentAccommodation': 'accommodation_view',
92              'StudentClearance': 'clearance_view',
93              'StudentPersonal': None,
94              'StudentStudyCourse': 'study_course_view',
95              'StudentPume': 'pume_view',
96              }
97sos = context.portal_catalog(container_path=student_path)
98for so in sos:
99    row = {}
100    soo = so.getObject()
101    sod = soo.getContent()
102    row['id'] = soo.getId()
103    row['title'] = sod.Title()
104    row['url'] = soo.absolute_url()
105    row['type'] = so.portal_type
106    row['is_editable'] = mtool.checkPermission('Modify portal content', soo)
107    sv_link = s_view_links.get(so.portal_type,None) or "waeup_document_view"
108    row['s_view_link'] = "%s/%s" % (soo.absolute_url(),sv_link)
109    se_link = s_edit_links.get(so.portal_type,None)
110    row['s_edit_link'] = None
111    if se_link:
112        row['s_edit_link'] = "%s/%s" % (soo.absolute_url(),se_link)
113    row['review_state'] = so.review_state
114    row['display'] = so.review_state in ('opened','closed',)
115    items.append(row)
116info['items'] = items
117request.set('student_id',student_id)
118request.set('student_url',info['url'])
119return info
Note: See TracBrowser for help on using the repository browser.