source: WAeUP_SRP/trunk/skins/waeup_student/getStudyCourseInfo.py @ 1492

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

create level button, create_level function

  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1## Script (Python) "getStudyCourseInfo"
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: getStudyCourseInfo.py 1492 2007-02-25 16:24:11Z joachim $
11"""
12return Info about the Students StudyCourse
13"""
14request = context.REQUEST
15
16wftool = context.portal_workflow
17path_info = request.get('PATH_INFO').split('/')
18
19info = {}
20info['is_so'] = context.isSectionOfficer()
21info['action'] = "%s" % context.campus.absolute_url()
22info['choosen_ids'] = request.get('ids',[])
23course  = info['doc'] = context.getContent()
24student_id = context.getStudentId()
25res = context.students_catalog(id = student_id)
26if not res:
27    return None
28sbrain = res[0]
29info['student'] = sbrain
30cert_id = sbrain.course
31res = context.portal_catalog(portal_type = "Certificate", id = cert_id)
32ci = {}
33if res:
34    info['cert_id'] = cert_id
35    brain = res[0]
36    ci['study_course'] = brain.getId
37    ci['title'] = brain.Title
38    pl = brain.getPath().split('/')
39    ci['faculty'] = pl[-4]
40    ci['department'] = pl[-3]
41    info['course_doc'] = ci
42else:
43    info['course'] = None
44items = []
45current_level = sbrain.level
46levels = context.objectIds()
47review_state = wftool.getInfoFor(context,'review_state',None)
48if review_state != 'content_addable':
49    wftool.doActionFor(context,'close_for_edit')
50student_review_state = context.getStudentReviewState()
51may_register = 1 or student_review_state in ('shool_fee_payed',)
52levels.sort()
53info['create_level'] = None
54if may_register:
55    info['create_level'] = current_level
56for l in levels:
57    row = {}
58    row['id'] = l
59    row['title'] = "Level %s" % l
60    row['url'] = "%s/%s" % (context.absolute_url(),l)
61    items.append(row)
62
63info['items'] = items
64return info
Note: See TracBrowser for help on using the repository browser.