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

Last change on this file since 2942 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
RevLine 
[845]1## Script (Python) "getStudyCourseInfo"
[723]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##
[805]10# $Id: getStudyCourseInfo.py 2876 2007-12-07 13:55:43Z joachim $
[723]11"""
12return Info about the Students StudyCourse
13"""
[2876]14import DateTime
[2855]15from Products.AdvancedQuery import Eq, Between, Le,In
[1783]16
17mtool = context.portal_membership
18if mtool.isAnonymousUser():
19    return None
20
[1494]21try:
22    from Products.zdb import set_trace
23except:
24    def set_trace():
25        pass
[2876]26import logging
27logger = logging.getLogger('Skins.getStudyCourseInfo')
[1494]28
[723]29request = context.REQUEST
30
[1490]31wftool = context.portal_workflow
[723]32path_info = request.get('PATH_INFO').split('/')
33
34info = {}
[1380]35info['is_so'] = context.isSectionOfficer()
[1650]36info['action'] = "%s" % context.absolute_url()
[723]37info['choosen_ids'] = request.get('ids',[])
[1380]38course  = info['doc'] = context.getContent()
39student_id = context.getStudentId()
[2876]40student_record = context.students_catalog.getRecordByKey(student_id)
41if not student_record:
[1380]42    return None
[2876]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
[1380]68ci = {}
[2876]69ci['study_course'] = student_record.course
70ci['faculty'] = student_record.faculty
71ci['department'] = student_record.department
72info['course_doc'] = ci
[2010]73
[723]74items = []
[2483]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
[2876]95current_level = student_record.level
[1492]96levels = context.objectIds()
97review_state = wftool.getInfoFor(context,'review_state',None)
[2876]98student_review_state = student_record.review_state
[2752]99#if review_state != 'content_addable' and student_review_state == 'school_fee_paid': #and context.isStudent():
100#    wftool.doActionFor(context,'close_for_edit')
[2674]101
[2664]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\
[2674]107               current_level == '100' or\
[2876]108               (student_record.mode.startswith('de') and current_level == '200'))
[2678]109
[2674]110missing_data = has_paid and\
111               current_level not in levels and\
[2876]112               not (previous_verdict or student_record.level) and\
[2674]113               not (current_level == '100' or\
[2876]114               (student_record.mode.startswith('de') and current_level == '200'))
[2664]115
[2674]116info['missing_data'] = missing_data
[1492]117levels.sort()
118info['create_level'] = None
[2640]119student_levels_voc = context.portal_vocabularies.student_levels
[2678]120if may_register:
[1492]121    info['create_level'] = current_level
[2640]122    info['create_level_str'] = student_levels_voc.get(current_level)
[1492]123for l in levels:
124    row = {}
125    row['id'] = l
[2640]126    #row['title'] = "Level %s" % l
127    row['title'] = student_levels_voc.get(l)
[1492]128    row['url'] = "%s/%s" % (context.absolute_url(),l)
129    items.append(row)
[1380]130
[723]131info['items'] = items
[1504]132
[2483]133
134
[723]135return info
[1504]136
Note: See TracBrowser for help on using the repository browser.