source: WAeUP_SRP/trunk/skins/waeup_academics/getLevelInfo.py @ 911

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

new local roles implemented
role SectionOfficer? not yet tested

  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1## Script (Python) "getLevelInfo"
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: getLevelInfo.py 911 2006-11-20 15:11:29Z henrik $
11"""
12return Info about the Faculties
13"""
14request = context.REQUEST
15
16wf = context.portal_workflow
17mtool = context.portal_membership
18path_info = request.get('PATH_INFO').split('/')
19try:
20    i = int(path_info[-1])
21    p = 0
22except:
23    p = 1
24info = {}
25pt = request.get('PATH_TRANSLATED').split('/')
26
27dep_id = pt[-(3+p)]
28cert_id = pt[-(2+p)]
29level_id = pt[-(1+p)]
30info['is_sm'] = context.isSectionManager()
31info['is_so'] = context.isSectionOfficer()
32info['is_student'] = context.isStudent()
33info['action'] = "%s" % context.absolute_url()
34info['choosen_ids'] = request.get('ids',[])
35info['doc'] = context.getContent()
36brain = context.portal_catalog(meta_type="Certificate",id = cert_id)[-1]
37cp = brain.getPath()
38info['container_path'] = cp
39info['dep_id'] = dep_id
40info['cert_id'] = cert_id
41
42res = context.portal_catalog(meta_type="CertificateCourse", container_path="%s/%s" % (cp,level_id))
43first = []
44second = []
45for r in res:
46    row = {}
47    ro = r.getObject()
48    rd = ro.getContent()
49    row['id'] = r.getId
50    row['title'] = rd.Title()
51    row['core'] = rd.core_or_elective
52    row['semester'] = rd.semester
53    row['url'] = ro.absolute_url()
54    row['review_state'] = wf.getInfoFor(ro,'review_state','None')
55    row['is_editable'] = mtool.checkPermission('Modify portal content', ro)
56    if rd.semester == 'first':
57        first.append(row)
58    else:
59        second.append(row)
60first.sort()
61second.sort()
62info['first'] = first
63info['second'] = second
64return info
Note: See TracBrowser for help on using the repository browser.