source: WAeUP_SRP/trunk/skins/waeup_futminna/getStudyCourseInfo.py @ 8794

Last change on this file since 8794 was 6862, checked in by Henrik Bettermann, 13 years ago

Change of functional specification: All students (except those in level 100) should be able to register 100L carryover courses.

  • Property svn:keywords set to Id
File size: 3.8 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 6862 2011-10-05 06:39:58Z 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
54ci = {}
55ci['study_course'] = student_record.course
56ci['faculty'] = student_record.faculty
57ci['department'] = student_record.department
58info['course_doc'] = ci
59
60items = []
61
62if hasattr(course,'current_verdict'):
63    try:
64        info['verdict'] = context.portal_vocabularies.verdicts.get(course.current_verdict).upper()
65    except:
66        info['verdict'] = course.current_verdict
67else:
68    info['verdict'] = ''
69
70if hasattr(course,'previous_verdict'):
71    try:
72        previous_verdict = course.previous_verdict
73        info['previous_verdict'] = context.portal_vocabularies.verdicts.get(course.previous_verdict).upper()
74    except:
75        info['previous_verdict'] = course.previous_verdict
76else:
77    info['previous_verdict'] = ''
78    previous_verdict = ''
79
80
81current_level = student_record.level
82levels = context.objectIds()
83review_state = wftool.getInfoFor(context,'review_state',None)
84student_review_state = student_record.review_state
85
86has_paid = student_review_state == 'school_fee_paid'
87
88may_register = has_paid and\
89               current_level not in levels and\
90               (previous_verdict in ('A','B','C','F','J','L','M','N','O','X','Z') or\
91               current_level in ('000','100') or\
92               (student_record.entry_mode.startswith('de') and current_level == '200') or\
93               (student_record.entry_mode.startswith('ph') and current_level == '300') or\
94               (student_record.entry_mode.startswith('pd') and current_level == '500'))  #fceokene only
95
96info['may_register_101'] = (int(current_level) > 199) and '100' not in levels and '101' not in levels
97
98missing_data = has_paid and\
99               current_level not in levels and\
100               not (previous_verdict or student_record.level) and\
101               not (current_level == '100' or\
102               (student_record.entry_mode.startswith('de') and current_level == '200') or\
103               (student_record.entry_mode.startswith('ph') and current_level == '300') or\
104               (student_record.entry_mode.startswith('pd') and current_level == '500'))  #fceokene only
105
106info['missing_data'] = missing_data
107levels.sort()
108info['create_level'] = None
109student_levels_voc = context.portal_vocabularies.student_levels
110if may_register:
111    info['create_level'] = current_level
112    info['create_level_str'] = student_levels_voc.get(current_level)
113for l in levels:
114    row = {}
115    row['id'] = l
116    #row['title'] = "Level %s" % l
117    row['title'] = student_levels_voc.get(l)
118    row['url'] = "%s/%s" % (context.absolute_url(),l)
119    items.append(row)
120
121info['items'] = items
122
123
124
125return info
126
Note: See TracBrowser for help on using the repository browser.