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

Last change on this file since 2889 was 2876, checked in by joachim, 17 years ago

simplyfied faster display of study_level

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