[731] | 1 | ## Script (Python) "folder_delete" |
---|
| 2 | ##bind container=container |
---|
| 3 | ##bind context=context |
---|
| 4 | ##bind namespace= |
---|
| 5 | ##bind script=script |
---|
| 6 | ##bind subpath=traverse_subpath |
---|
| 7 | ##parameters= |
---|
| 8 | ##title= |
---|
| 9 | ## |
---|
[805] | 10 | # $Id: add_course_result.py 1482 2007-02-23 16:56:46Z joachim $ |
---|
[731] | 11 | """ |
---|
[1482] | 12 | add a course_result object. |
---|
[731] | 13 | """ |
---|
[1482] | 14 | from urllib import urlencode |
---|
| 15 | request = context.REQUEST |
---|
| 16 | course_cat = context.courses_catalog |
---|
| 17 | from Products.AdvancedQuery import Eq, Between, Le,In |
---|
| 18 | aq_portal = context.portal_catalog.evalAdvancedQuery |
---|
| 19 | course_id = request.get('course_id') |
---|
| 20 | d = context.getCourseInfo(course_id) |
---|
| 21 | args = {} |
---|
| 22 | err = '' |
---|
| 23 | while True: |
---|
| 24 | if d['title'] == 'unknown': |
---|
| 25 | err = "no such course" |
---|
| 26 | break |
---|
| 27 | if context.hasObject(course_id): |
---|
| 28 | err = "course already exists" |
---|
| 29 | break |
---|
| 30 | if context.hasObject("%s_co" % course_id): |
---|
| 31 | err = "course already exists as carryover" |
---|
| 32 | break |
---|
| 33 | break |
---|
[731] | 34 | |
---|
[1482] | 35 | if err: |
---|
| 36 | args['course_id'] = course_id |
---|
| 37 | args['error'] = err |
---|
| 38 | url = "%s?%s" % (context.absolute_url(),urlencode(args)) |
---|
| 39 | return request.RESPONSE.redirect(url) |
---|
| 40 | ##cert_id = context.aq_parent.getContent().study_course |
---|
| 41 | ##res = context.portal_catalog(portal_type="Certificate", id = cert_id) |
---|
| 42 | ##l = [] |
---|
| 43 | ##if res: |
---|
| 44 | ## cert = res[0] |
---|
| 45 | ## path = cert.getPath() |
---|
| 46 | ## query = Eq("path",path) &\ |
---|
| 47 | ## Eq('portal_type','CertificateCourse') &\ |
---|
| 48 | ## Eq('SearchableText', "%s" % student.level) &\ |
---|
| 49 | ## Eq('id',course_id) |
---|
| 50 | ##course = aq_portal(query)[0] |
---|
| 51 | cr_id = context.invokeFactory('StudentCourseResult',course_id) |
---|
| 52 | ##d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective') |
---|
| 53 | ##getattr(context,cr_id).getContent().edit(mapping=d) |
---|
| 54 | args['course_id'] = course_id |
---|
| 55 | from urllib import urlencode |
---|
| 56 | url = "%s?%s" % (context.absolute_url(),urlencode(args)) |
---|
| 57 | return request.RESPONSE.redirect(url) |
---|
| 58 | |
---|