source: WAeUP_SRP/trunk/skins/waeup_student/register_courses.py @ 6645

Last change on this file since 6645 was 5457, checked in by Henrik Bettermann, 14 years ago

resolve #687

File size: 2.1 KB
RevLine 
[1571]1## Script (Python) "register_courses"
[1513]2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
[1590]7##parameters=REQUEST=None, student=None, action_after_reject=None, action_after_validate=None
[1513]8##title=
9##
[5457]10# $Id: register_courses.py 1504 2007-02-26 21:20:40Z henrik $
[1513]11"""
12close the Students StudyLevel
13"""
[1583]14from Products.CMFCore.WorkflowCore import WorkflowException
[1513]15try:
16    from Products.zdb import set_trace
17except:
18    def set_trace():
19        pass
20
[1606]21from urllib import urlencode
[1590]22
[1513]23request = context.REQUEST
24mtool = context.portal_membership
25member = mtool.getAuthenticatedMember()
26member_id = str(member)
27import logging
[1571]28logger = logging.getLogger('Skins.register_courses')
[1513]29
30wftool = context.portal_workflow
31students_folder = context.portal_url.getPortalObject().campus.students
[1583]32student_id = context.getStudentId()
33student = getattr(students_folder,student_id)
[2091]34
[5457]35info = context.getStudyLevelInfo()
36if info['credits_exceeded']:
37    args = {}
38    args['portal_status_message'] = "Your total credits exceed %s!" % info['max_credits']
39    url = context.absolute_url() + '?' + urlencode(args)
40    logger.info('%s tried to register course list with credits exceeded, probably by pressing the browser back button' % (student_id))
41    return REQUEST.RESPONSE.redirect(url)
42
[1583]43try:
[2091]44    wftool.doActionFor(student,'register_courses')
45except WorkflowException,E:
46    logger.info('%s WorkflowException %s for %s' % (member_id,E,student_id))
47    return request.RESPONSE.redirect("%s" % context.absolute_url())
48
49try:
[1583]50    wftool.doActionFor(context,'close')
51except WorkflowException,E:
[2032]52    #logger.info('%s WorkflowException %s for %s' % (member_id,E,student_id))
53    #return request.RESPONSE.redirect("%s" % context.absolute_url())
54    pass
[2091]55
[1589]56logger.info('%s registered course list of %s' % (member_id,student_id))
[1591]57args = {}
[1590]58psm = "You successfully submitted your course list!"
59args['portal_status_message'] = psm
[1606]60if action_after_validate:
61    url = context.absolute_url() + '/' + action_after_validate + '?' + urlencode(args)
62else:
63    url = context.absolute_url() + '?' + urlencode(args)
[1590]64return REQUEST.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.