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

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

Ghana changes

  • Property svn:keywords set to Id
File size: 1.4 KB
RevLine 
[1519]1## Script (Python) "add_course_result"
[731]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 1520 2007-03-06 18:26:05Z joachim $
[731]11"""
[1519]12add a StudentCourseResult object
[731]13"""
[1482]14from urllib import urlencode
[1520]15try:
16    from Products.zdb import set_trace
17except:
18    def set_trace():
19        pass
[1482]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':
[1519]30        err = "No such course"
[1482]31        break
32    if context.hasObject(course_id):
[1519]33        err = "Course already exists"
[1482]34        break
35    if context.hasObject("%s_co" % course_id):
[1519]36        err = "Course already exists as carryover course"
[1482]37        break
38    break
[731]39
[1482]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)
[1520]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')
[1482]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.