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

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

faster certificate search ?

  • Property svn:keywords set to Id
File size: 3.5 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 2855 2007-12-04 15:47:06Z joachim $
[723]11"""
12return Info about the Students StudyCourse
13"""
[2855]14from Products.AdvancedQuery import Eq, Between, Le,In
[1783]15
16mtool = context.portal_membership
17if mtool.isAnonymousUser():
18    return None
19
[1494]20try:
21    from Products.zdb import set_trace
22except:
23    def set_trace():
24        pass
25
[723]26request = context.REQUEST
27
[1490]28wftool = context.portal_workflow
[723]29path_info = request.get('PATH_INFO').split('/')
30
31info = {}
[1380]32info['is_so'] = context.isSectionOfficer()
[1650]33info['action'] = "%s" % context.absolute_url()
[723]34info['choosen_ids'] = request.get('ids',[])
[1380]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]
[1403]41info['student'] = sbrain
[1380]42cert_id = sbrain.course
[2855]43res = context.portal_catalog_real.evalAdvancedQuery(Eq('id', cert_id) &
44                                                    Eq('portal_type', "Certificate"))
[1380]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:
[1816]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
[2010]62
[723]63items = []
[2483]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
[1492]84current_level = sbrain.level
85levels = context.objectIds()
86review_state = wftool.getInfoFor(context,'review_state',None)
[2664]87student_review_state = sbrain.review_state
[2752]88#if review_state != 'content_addable' and student_review_state == 'school_fee_paid': #and context.isStudent():
89#    wftool.doActionFor(context,'close_for_edit')
[2674]90
[2664]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\
[2674]96               current_level == '100' or\
97               (sbrain.mode.startswith('de') and current_level == '200'))
[2678]98
[2674]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\
[2678]103               (sbrain.mode.startswith('de') and current_level == '200'))
[2664]104
[2674]105info['missing_data'] = missing_data
[1492]106levels.sort()
107info['create_level'] = None
[2640]108student_levels_voc = context.portal_vocabularies.student_levels
[2678]109if may_register:
[1492]110    info['create_level'] = current_level
[2640]111    info['create_level_str'] = student_levels_voc.get(current_level)
[1492]112for l in levels:
113    row = {}
114    row['id'] = l
[2640]115    #row['title'] = "Level %s" % l
116    row['title'] = student_levels_voc.get(l)
[1492]117    row['url'] = "%s/%s" % (context.absolute_url(),l)
118    items.append(row)
[1380]119
[723]120info['items'] = items
[1504]121
[2483]122
123
[723]124return info
[1504]125
Note: See TracBrowser for help on using the repository browser.