[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 1417 2007-02-15 10:56:43Z joachim $ |
---|
[723] | 11 | """ |
---|
| 12 | return Info about the Students StudyCourse |
---|
| 13 | """ |
---|
| 14 | request = context.REQUEST |
---|
| 15 | |
---|
| 16 | wf = context.portal_workflow |
---|
| 17 | path_info = request.get('PATH_INFO').split('/') |
---|
| 18 | |
---|
| 19 | info = {} |
---|
[1380] | 20 | info['is_so'] = context.isSectionOfficer() |
---|
[723] | 21 | info['action'] = "%s" % context.campus.absolute_url() |
---|
| 22 | info['choosen_ids'] = request.get('ids',[]) |
---|
[1380] | 23 | course = info['doc'] = context.getContent() |
---|
| 24 | student_id = context.getStudentId() |
---|
| 25 | res = context.students_catalog(id = student_id) |
---|
| 26 | if not res: |
---|
| 27 | return None |
---|
| 28 | sbrain = res[0] |
---|
[1403] | 29 | info['student'] = sbrain |
---|
[1380] | 30 | cert_id = sbrain.course |
---|
| 31 | res = context.portal_catalog(portal_type = "Certificate", id = cert_id) |
---|
| 32 | ci = {} |
---|
| 33 | if res: |
---|
| 34 | info['cert_id'] = cert_id |
---|
| 35 | brain = res[0] |
---|
| 36 | ci['study_course'] = brain.getId |
---|
| 37 | ci['title'] = brain.Title |
---|
| 38 | pl = brain.getPath().split('/') |
---|
| 39 | ci['faculty'] = pl[-4] |
---|
| 40 | ci['department'] = pl[-3] |
---|
| 41 | info['course_doc'] = ci |
---|
| 42 | else: |
---|
| 43 | info['course'] = None |
---|
[723] | 44 | items = [] |
---|
[1380] | 45 | current_level = sbrain.level |
---|
| 46 | levels = context.objectIds() |
---|
[1417] | 47 | #levels.sort() |
---|
| 48 | #if int(current_level) > int(levels[-1]): |
---|
| 49 | if not levels: |
---|
[1380] | 50 | context.invokeFactory('StudentStudyLevel',"%s" % current_level) |
---|
| 51 | level = getattr(context,"%s" % current_level) |
---|
| 52 | level.getContent().edit(mapping={'session': "2006/2007"}) |
---|
| 53 | context.portal_workflow.doActionFor(level,'open') |
---|
| 54 | context.portal_workflow.doActionFor(level,'close_for_edit') |
---|
| 55 | levels.append(current_level) |
---|
| 56 | #from Products.zdb import set_trace;set_trace() |
---|
[723] | 57 | for l in levels: |
---|
| 58 | row = {} |
---|
[1380] | 59 | row['id'] = l |
---|
| 60 | row['title'] = "Level %s" % l |
---|
| 61 | row['url'] = "%s/%s" % (context.absolute_url(),l) |
---|
[723] | 62 | items.append(row) |
---|
[1380] | 63 | |
---|
[723] | 64 | info['items'] = items |
---|
| 65 | return info |
---|