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

Last change on this file since 1571 was 1571, checked in by Henrik Bettermann, 18 years ago

new logging format Part 4 (rest)

  • Property svn:keywords set to Id
File size: 2.1 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 1571 2007-03-17 15:25:56Z henrik $
[731]11"""
[1519]12add a StudentCourseResult object
[731]13"""
[1571]14
15import logging
16logger = logging.getLogger('Skins.add_course_result')
17
[1482]18from urllib import urlencode
[1520]19try:
20    from Products.zdb import set_trace
21except:
22    def set_trace():
23        pass
[1482]24request = context.REQUEST
25course_cat = context.courses_catalog
26from Products.AdvancedQuery import Eq, Between, Le,In
27aq_portal = context.portal_catalog.evalAdvancedQuery
28course_id = request.get('course_id')
[1571]29
30mtool = context.portal_membership
31member = mtool.getAuthenticatedMember()
32
33
[1482]34d = context.getCourseInfo(course_id)
35args = {}
36err = ''
37while True:
38    if d['title'] == 'unknown':
[1571]39        err = "No such course!"
40        logger.info('%s tried to add StudentCourseResult object %s for non-existing course' % (member,course_id))
[1482]41        break
42    if context.hasObject(course_id):
[1571]43        err = "Course already exists!"
44        logger.info('%s tried to add StudentCourseResult object %s which is already in course list' % (member,course_id))
[1482]45        break
46    if context.hasObject("%s_co" % course_id):
[1571]47        err = "Course already exists as carryover course!"
48        logger.info('%s tried to add StudentCourseResult object %s which already exists as carryover course' % (member,course_id))
[1482]49        break
50    break
[731]51
[1482]52if err:
53    args['course_id'] = course_id
[1571]54    #args['error'] = err
55    args['portal_status_message'] = err
[1482]56    url = "%s?%s" % (context.absolute_url(),urlencode(args))
57    return request.RESPONSE.redirect(url)
[1571]58
59   
[1482]60cr_id = context.invokeFactory('StudentCourseResult',course_id)
[1520]61#set_trace()
62cr = getattr(context,cr_id)
63context.portal_workflow.doActionFor(cr,'open')
64cr.getContent().edit(mapping=d)
65context.portal_workflow.doActionFor(cr,'close')
[1482]66args['course_id'] = course_id
[1571]67
68logger.info('%s added StudentCourseResult object %s' % (member,course_id))   
69
[1482]70from urllib import urlencode
71url = "%s?%s" % (context.absolute_url(),urlencode(args))
72return request.RESPONSE.redirect(url)
73
Note: See TracBrowser for help on using the repository browser.