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

Last change on this file since 3702 was 3619, checked in by Henrik Bettermann, 16 years ago

change permissions

  • Property svn:keywords set to Id
File size: 4.3 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 3619 2008-08-08 06:39:00Z henrik $
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
32# path_info = request.get('PATH_INFO').split('/')
33
34# info = {}
35info = context.waeup_tool.getAccessInfo(context)
36student_id = info['student_id']
37if student_id is None:
38    return None
39
40#info['is_so'] = context.isSectionOfficer()
41info['is_so'] = info['is_sectionofficer']
42info['action'] = "%s" % context.absolute_url()
43info['choosen_ids'] = request.get('ids',[])
44try:
45    course  = info['doc'] = context.getContent()
46except:
47    return None
48#student_id = context.getStudentId()
49student_record = context.students_catalog.getRecordByKey(student_id)
50if not student_record:
51    return None
52info['student'] = student_record
53cert_id = student_record.course
54# logger.info("before search")
55# starttime = DateTime.DateTime().timeTime()
56# res = context.portal_catalog_real.evalAdvancedQuery(Eq('id', cert_id)) # &
57#                                                    Eq('portal_type', "Certificate"))
58# logger.info("searchtime %f" % (DateTime.DateTime().timeTime() - starttime))
59# if True:
60#     #info['cert_id'] = cert_id
61#     # brain = res[0]
62#     # ci['title'] = brain.Title
63#     # pl = brain.getPath().split('/')
64#     # ci['faculty'] = pl[-4]
65#     # ci['department'] = pl[-3]
66#     ci['study_course'] = student_record.course
67#     ci['faculty'] = student_record.faculty
68#     ci['department'] = student_record.department
69#     info['course_doc'] = ci
70# else:
71#     info['cert_id'] = 'N/A'
72#     ci['study_course'] = 'N/A'
73#     ci['title'] = 'N/A'
74#     ci['faculty'] = 'N/A'
75#     ci['department'] = 'N/A'
76#     info['course_doc'] = ci
77ci = {}
78ci['study_course'] = student_record.course
79ci['faculty'] = student_record.faculty
80ci['department'] = student_record.department
81info['course_doc'] = ci
82
83items = []
84
85if hasattr(course,'current_verdict'):
86    try:
87        info['verdict'] = context.portal_vocabularies.verdicts.get(course.current_verdict).upper()
88    except:
89        info['verdict'] = course.current_verdict
90else:
91    info['verdict'] = ''
92
93if hasattr(course,'previous_verdict'):
94    try:
95        previous_verdict = course.previous_verdict
96        info['previous_verdict'] = context.portal_vocabularies.verdicts.get(course.previous_verdict).upper()
97    except:
98        info['previous_verdict'] = course.previous_verdict
99else:
100    info['previous_verdict'] = ''
101    previous_verdict = ''
102
103
104current_level = student_record.level
105levels = context.objectIds()
106review_state = wftool.getInfoFor(context,'review_state',None)
107student_review_state = student_record.review_state
108#if review_state != 'content_addable' and student_review_state == 'school_fee_paid': #and context.isStudent():
109#    wftool.doActionFor(context,'close_for_edit')
110
111has_paid = student_review_state == 'school_fee_paid'
112
113may_register = has_paid and\
114               current_level not in levels and\
115               (previous_verdict in ('A','B','C','F','J','L','M') or\
116               current_level in ('000','100') or\
117               (student_record.mode.startswith('de') and current_level == '200'))
118
119missing_data = has_paid and\
120               current_level not in levels and\
121               not (previous_verdict or student_record.level) and\
122               not (current_level == '100' or\
123               (student_record.mode.startswith('de') and current_level == '200'))
124
125info['missing_data'] = missing_data
126levels.sort()
127info['create_level'] = None
128student_levels_voc = context.portal_vocabularies.student_levels
129if may_register:
130    info['create_level'] = current_level
131    info['create_level_str'] = student_levels_voc.get(current_level)
132for l in levels:
133    row = {}
134    row['id'] = l
135    #row['title'] = "Level %s" % l
136    row['title'] = student_levels_voc.get(l)
137    row['url'] = "%s/%s" % (context.absolute_url(),l)
138    items.append(row)
139
140info['items'] = items
141
142
143
144return info
145
Note: See TracBrowser for help on using the repository browser.