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

Last change on this file since 1783 was 1783, checked in by Henrik Bettermann, 17 years ago
  • assertViewable removed and page templates adjusted, so that no traceback occurs.
  • 'Previous Session' action added
  • waeup_content_master.pt removed
  • and more
  • Property svn:keywords set to Id
File size: 2.2 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 1783 2007-05-15 07:49:50Z henrik $
11"""
12return Info about the Students StudyCourse
13"""
14
15mtool = context.portal_membership
16if mtool.isAnonymousUser():
17    return None
18
19try:
20    from Products.zdb import set_trace
21except:
22    def set_trace():
23        pass
24
25request = context.REQUEST
26
27wftool = context.portal_workflow
28path_info = request.get('PATH_INFO').split('/')
29
30info = {}
31info['is_so'] = context.isSectionOfficer()
32info['action'] = "%s" % context.absolute_url()
33info['choosen_ids'] = request.get('ids',[])
34course  = info['doc'] = context.getContent()
35student_id = context.getStudentId()
36res = context.students_catalog(id = student_id)
37if not res:
38    return None
39sbrain = res[0]
40info['student'] = sbrain
41cert_id = sbrain.course
42res = context.portal_catalog(portal_type = "Certificate", id = cert_id)
43ci = {}
44if res:
45    info['cert_id'] = cert_id
46    brain = res[0]
47    ci['study_course'] = brain.getId
48    ci['title'] = brain.Title
49    pl = brain.getPath().split('/')
50    ci['faculty'] = pl[-4]
51    ci['department'] = pl[-3]
52    info['course_doc'] = ci
53else:
54    info['course'] = None
55items = []
56current_level = sbrain.level
57levels = context.objectIds()
58review_state = wftool.getInfoFor(context,'review_state',None)
59student_review_state = context.getStudentReviewState()
60if review_state != 'content_addable' and student_review_state == 'school_fee_paid': #and context.isStudent():
61    wftool.doActionFor(context,'close_for_edit')
62may_register = (student_review_state in ('school_fee_paid',)) and\
63               current_level not in levels and\
64               (sbrain.verdict in ('A','B','C','J') or sbrain.jamb_reg_no.startswith('6'))
65
66levels.sort()
67info['create_level'] = None
68if may_register:
69    info['create_level'] = current_level
70for l in levels:
71    row = {}
72    row['id'] = l
73    row['title'] = "Level %s" % l
74    row['url'] = "%s/%s" % (context.absolute_url(),l)
75    items.append(row)
76
77info['items'] = items
78
79try:
80    info['verdict'] = context.portal_vocabularies.verdicts.get(info['doc'].current_verdict).upper()
81except:
82    info['verdict'] = course.current_verdict
83
84return info
85
Note: See TracBrowser for help on using the repository browser.