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

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

propset Id

  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1## Script (Python) "cpsdocument_edit"
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 805 2006-11-09 09:38:29Z joachim $
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_manager'] = context.isManager()
31info['is_student'] = context.isStudent()
32info['action'] = "%s" % context.absolute_url()
33info['choosen_ids'] = request.get('ids',[])
34info['doc'] = context.getContent()
35brain = context.portal_catalog(meta_type="Certificate",id = cert_id)[-1]
36cp = brain.getPath()
37info['container_path'] = cp
38info['dep_id'] = dep_id
39info['cert_id'] = cert_id
40
41res = context.portal_catalog(meta_type="CertificateCourse", container_path="%s/%s" % (cp,level_id))
42first = []
43second = []
44for r in res:
45    row = {}
46    ro = r.getObject()
47    rd = ro.getContent()
48    row['id'] = r.getId
49    row['title'] = rd.Title()
50    row['core'] = rd.core_or_elective
51    row['semester'] = rd.semester
52    row['url'] = ro.absolute_url()
53    row['review_state'] = wf.getInfoFor(ro,'review_state','None')
54    row['is_editable'] = mtool.checkPermission('Modify portal content', ro)
55    if rd.semester == 'first':
56        first.append(row)
57    else:
58        second.append(row)
59first.sort()
60second.sort()
61info['first'] = first
62info['second'] = second
63return info
Note: See TracBrowser for help on using the repository browser.