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

Last change on this file since 1560 was 1520, checked in by joachim, 18 years ago

Ghana changes

  • Property svn:keywords set to Id
File size: 1.4 KB
Line 
1## Script (Python) "add_course_result"
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 1520 2007-03-06 18:26:05Z joachim $
11"""
12add a StudentCourseResult object
13"""
14from urllib import urlencode
15try:
16    from Products.zdb import set_trace
17except:
18    def set_trace():
19        pass
20request = context.REQUEST
21course_cat = context.courses_catalog
22from Products.AdvancedQuery import Eq, Between, Le,In
23aq_portal = context.portal_catalog.evalAdvancedQuery
24course_id = request.get('course_id')
25d = context.getCourseInfo(course_id)
26args = {}
27err = ''
28while True:
29    if d['title'] == 'unknown':
30        err = "No such course"
31        break
32    if context.hasObject(course_id):
33        err = "Course already exists"
34        break
35    if context.hasObject("%s_co" % course_id):
36        err = "Course already exists as carryover course"
37        break
38    break
39
40if err:
41    args['course_id'] = course_id
42    args['error'] = err
43    url = "%s?%s" % (context.absolute_url(),urlencode(args))
44    return request.RESPONSE.redirect(url)
45cr_id = context.invokeFactory('StudentCourseResult',course_id)
46#set_trace()
47cr = getattr(context,cr_id)
48context.portal_workflow.doActionFor(cr,'open')
49cr.getContent().edit(mapping=d)
50context.portal_workflow.doActionFor(cr,'close')
51args['course_id'] = course_id
52from urllib import urlencode
53url = "%s?%s" % (context.absolute_url(),urlencode(args))
54return request.RESPONSE.redirect(url)
55
Note: See TracBrowser for help on using the repository browser.