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

Last change on this file since 17949 was 6862, checked in by Henrik Bettermann, 13 years ago

Change of functional specification: All students (except those in level 100) should be able to register 100L carryover courses.

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