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 1653 2007-03-28 02:35:25Z uli $ |
---|
11 | """ |
---|
12 | return Info about the Students StudyCourse |
---|
13 | """ |
---|
14 | try: |
---|
15 | from Products.zdb import set_trace |
---|
16 | except: |
---|
17 | def set_trace(): |
---|
18 | pass |
---|
19 | |
---|
20 | request = context.REQUEST |
---|
21 | |
---|
22 | wftool = context.portal_workflow |
---|
23 | path_info = request.get('PATH_INFO').split('/') |
---|
24 | |
---|
25 | info = {} |
---|
26 | info['is_so'] = context.isSectionOfficer() |
---|
27 | info['action'] = "%s" % context.absolute_url() |
---|
28 | info['choosen_ids'] = request.get('ids',[]) |
---|
29 | course = info['doc'] = context.getContent() |
---|
30 | student_id = context.getStudentId() |
---|
31 | res = context.students_catalog(id = student_id) |
---|
32 | if not res: |
---|
33 | return None |
---|
34 | sbrain = res[0] |
---|
35 | info['student'] = sbrain |
---|
36 | cert_id = sbrain.course |
---|
37 | res = context.portal_catalog(portal_type = "Certificate", id = cert_id) |
---|
38 | ci = {} |
---|
39 | if res: |
---|
40 | info['cert_id'] = cert_id |
---|
41 | brain = res[0] |
---|
42 | ci['study_course'] = brain.getId |
---|
43 | ci['title'] = brain.Title |
---|
44 | pl = brain.getPath().split('/') |
---|
45 | ci['faculty'] = pl[-4] |
---|
46 | ci['department'] = pl[-3] |
---|
47 | info['course_doc'] = ci |
---|
48 | else: |
---|
49 | info['course'] = None |
---|
50 | items = [] |
---|
51 | current_level = sbrain.level |
---|
52 | levels = context.objectIds() |
---|
53 | review_state = wftool.getInfoFor(context,'review_state',None) |
---|
54 | student_review_state = context.getStudentReviewState() |
---|
55 | if review_state != 'content_addable' and student_review_state == 'school_fee_paid': #and context.isStudent(): |
---|
56 | wftool.doActionFor(context,'close_for_edit') |
---|
57 | may_register = (student_review_state in ('school_fee_paid',)) and\ |
---|
58 | current_level not in levels and\ |
---|
59 | (sbrain.verdict in ('A','B','C') or sbrain.jamb_reg_no.startswith('6')) |
---|
60 | |
---|
61 | levels.sort() |
---|
62 | info['create_level'] = None |
---|
63 | if may_register: |
---|
64 | info['create_level'] = current_level |
---|
65 | for l in levels: |
---|
66 | row = {} |
---|
67 | row['id'] = l |
---|
68 | row['title'] = "Level %s" % l |
---|
69 | row['url'] = "%s/%s" % (context.absolute_url(),l) |
---|
70 | items.append(row) |
---|
71 | |
---|
72 | info['items'] = items |
---|
73 | |
---|
74 | try: |
---|
75 | info['verdict'] = context.portal_vocabularies.verdicts.get(info['doc'].current_verdict).upper() |
---|
76 | except: |
---|
77 | info['verdict'] = course.current_verdict |
---|
78 | |
---|
79 | return info |
---|
80 | |
---|