source: WAeUP_SRP/base/skins/waeup_student/getStudyCourseInfo.py @ 2865

Last change on this file since 2865 was 2855, checked in by joachim, 17 years ago

faster certificate search ?

  • Property svn:keywords set to Id
File size: 3.5 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 2855 2007-12-04 15:47:06Z joachim $
11"""
12return Info about the Students StudyCourse
13"""
14from Products.AdvancedQuery import Eq, Between, Le,In
15
16mtool = context.portal_membership
17if mtool.isAnonymousUser():
18    return None
19
20try:
21    from Products.zdb import set_trace
22except:
23    def set_trace():
24        pass
25
26request = context.REQUEST
27
28wftool = context.portal_workflow
29path_info = request.get('PATH_INFO').split('/')
30
31info = {}
32info['is_so'] = context.isSectionOfficer()
33info['action'] = "%s" % context.absolute_url()
34info['choosen_ids'] = request.get('ids',[])
35course  = info['doc'] = context.getContent()
36student_id = context.getStudentId()
37res = context.students_catalog(id = student_id)
38if not res:
39    return None
40sbrain = res[0]
41info['student'] = sbrain
42cert_id = sbrain.course
43res = context.portal_catalog_real.evalAdvancedQuery(Eq('id', cert_id) &
44                                                    Eq('portal_type', "Certificate"))
45ci = {}
46if res:
47    info['cert_id'] = cert_id
48    brain = res[0]
49    ci['study_course'] = brain.getId
50    ci['title'] = brain.Title
51    pl = brain.getPath().split('/')
52    ci['faculty'] = pl[-4]
53    ci['department'] = pl[-3]
54    info['course_doc'] = ci
55else:
56    info['cert_id'] = 'N/A'
57    ci['study_course'] = 'N/A'
58    ci['title'] = 'N/A'
59    ci['faculty'] = 'N/A'
60    ci['department'] = 'N/A'
61    info['course_doc'] = ci
62
63items = []
64
65if hasattr(course,'current_verdict'):
66    try:
67        info['verdict'] = context.portal_vocabularies.verdicts.get(course.current_verdict).upper()
68    except:
69        info['verdict'] = course.current_verdict
70else:
71    info['verdict'] = ''
72
73if hasattr(course,'previous_verdict'):
74    try:
75        previous_verdict = course.previous_verdict
76        info['previous_verdict'] = context.portal_vocabularies.verdicts.get(course.previous_verdict).upper()
77    except:
78        info['previous_verdict'] = course.previous_verdict
79else:
80    info['previous_verdict'] = ''
81    previous_verdict = ''
82
83
84current_level = sbrain.level
85levels = context.objectIds()
86review_state = wftool.getInfoFor(context,'review_state',None)
87student_review_state = sbrain.review_state
88#if review_state != 'content_addable' and student_review_state == 'school_fee_paid': #and context.isStudent():
89#    wftool.doActionFor(context,'close_for_edit')
90
91has_paid = student_review_state == 'school_fee_paid'
92
93may_register = has_paid and\
94               current_level not in levels and\
95               (previous_verdict in ('A','B','C','F','J','L','M') or\
96               current_level == '100' or\
97               (sbrain.mode.startswith('de') and current_level == '200'))
98
99missing_data = has_paid and\
100               current_level not in levels and\
101               not (previous_verdict or sbrain.level) and\
102               not (current_level == '100' or\
103               (sbrain.mode.startswith('de') and current_level == '200'))
104
105info['missing_data'] = missing_data
106levels.sort()
107info['create_level'] = None
108student_levels_voc = context.portal_vocabularies.student_levels
109if may_register:
110    info['create_level'] = current_level
111    info['create_level_str'] = student_levels_voc.get(current_level)
112for l in levels:
113    row = {}
114    row['id'] = l
115    #row['title'] = "Level %s" % l
116    row['title'] = student_levels_voc.get(l)
117    row['url'] = "%s/%s" % (context.absolute_url(),l)
118    items.append(row)
119
120info['items'] = items
121
122
123
124return info
125
Note: See TracBrowser for help on using the repository browser.