source: WAeUP_SRP/trunk/skins/waeup_student/add_course_result.py @ 1492

Last change on this file since 1492 was 1482, checked in by joachim, 18 years ago

add course registration.
The Link to the study_level is disabled in study_course_view.pt,
but can be invoked manually. On first invocation the courses are created.

  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
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##
10# $Id: add_course_result.py 1482 2007-02-23 16:56:46Z joachim $
11"""
12add a course_result object.
13"""
14from urllib import urlencode
15request = context.REQUEST
16course_cat = context.courses_catalog
17from Products.AdvancedQuery import Eq, Between, Le,In
18aq_portal = context.portal_catalog.evalAdvancedQuery
19course_id = request.get('course_id')
20d = context.getCourseInfo(course_id)
21args = {}
22err = ''
23while 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
34
35if 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]
51cr_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)
54args['course_id'] = course_id
55from urllib import urlencode
56url = "%s?%s" % (context.absolute_url(),urlencode(args))
57return request.RESPONSE.redirect(url)
58
Note: See TracBrowser for help on using the repository browser.