[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 1380 2007-01-31 16:24:18Z 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] |
---|
| 29 | cert_id = sbrain.course |
---|
| 30 | res = context.portal_catalog(portal_type = "Certificate", id = cert_id) |
---|
| 31 | ci = {} |
---|
| 32 | if res: |
---|
| 33 | info['cert_id'] = cert_id |
---|
| 34 | brain = res[0] |
---|
| 35 | ci['study_course'] = brain.getId |
---|
| 36 | ci['title'] = brain.Title |
---|
| 37 | pl = brain.getPath().split('/') |
---|
| 38 | ci['faculty'] = pl[-4] |
---|
| 39 | ci['department'] = pl[-3] |
---|
| 40 | info['course_doc'] = ci |
---|
| 41 | else: |
---|
| 42 | info['course'] = None |
---|
[723] | 43 | items = [] |
---|
[1380] | 44 | current_level = sbrain.level |
---|
| 45 | levels = context.objectIds() |
---|
| 46 | if current_level not in levels: |
---|
| 47 | context.invokeFactory('StudentStudyLevel',"%s" % current_level) |
---|
| 48 | level = getattr(context,"%s" % current_level) |
---|
| 49 | level.getContent().edit(mapping={'session': "2006/2007"}) |
---|
| 50 | context.portal_workflow.doActionFor(level,'open') |
---|
| 51 | context.portal_workflow.doActionFor(level,'close_for_edit') |
---|
| 52 | levels.append(current_level) |
---|
| 53 | #from Products.zdb import set_trace;set_trace() |
---|
[723] | 54 | for l in levels: |
---|
| 55 | row = {} |
---|
[1380] | 56 | row['id'] = l |
---|
| 57 | row['title'] = "Level %s" % l |
---|
| 58 | row['url'] = "%s/%s" % (context.absolute_url(),l) |
---|
[723] | 59 | items.append(row) |
---|
[1380] | 60 | |
---|
[723] | 61 | info['items'] = items |
---|
| 62 | return info |
---|