[1571] | 1 | ## Script (Python) "reject_courses" |
---|
[1515] | 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 |
---|
[1515] | 8 | ##title= |
---|
| 9 | ## |
---|
| 10 | # $Id: getStudyCourseInfo.py 1504 2007-02-26 21:20:40Z henrik $ |
---|
| 11 | """ |
---|
| 12 | close the Students StudyLevel |
---|
| 13 | """ |
---|
[1589] | 14 | from Products.CMFCore.WorkflowCore import WorkflowException |
---|
[1515] | 15 | try: |
---|
| 16 | from Products.zdb import set_trace |
---|
| 17 | except: |
---|
| 18 | def set_trace(): |
---|
| 19 | pass |
---|
[1575] | 20 | from urllib import urlencode |
---|
[1515] | 21 | request = context.REQUEST |
---|
| 22 | mtool = context.portal_membership |
---|
| 23 | member = mtool.getAuthenticatedMember() |
---|
| 24 | member_id = str(member) |
---|
| 25 | import logging |
---|
[1571] | 26 | logger = logging.getLogger('Skins.reject_courses') |
---|
[1515] | 27 | |
---|
| 28 | wftool = context.portal_workflow |
---|
[2752] | 29 | try: |
---|
| 30 | wftool.doActionFor(context,'open') |
---|
| 31 | except: |
---|
| 32 | pass |
---|
| 33 | #wftool.doActionFor(context,'close_for_edit') |
---|
[1515] | 34 | students_folder = context.portal_url.getPortalObject().campus.students |
---|
[1589] | 35 | student_id = context.getStudentId() |
---|
| 36 | student = getattr(students_folder,student_id) |
---|
| 37 | try: |
---|
| 38 | wftool.doActionFor(student,'reject_courses') |
---|
| 39 | except WorkflowException,E: |
---|
| 40 | logger.info('%s WorkflowException %s for %s' % (member_id,E,student_id)) |
---|
| 41 | return request.RESPONSE.redirect("%s" % context.absolute_url()) |
---|
| 42 | logger.info('%s rejected course list of %s' % (member_id,student_id)) |
---|
[1575] | 43 | |
---|
| 44 | args = {} |
---|
[1587] | 45 | |
---|
[1575] | 46 | psm = "Student's course list has been rejected! Please fill and submit the form below!" |
---|
| 47 | subject = "Course list rejected" |
---|
| 48 | args['subject'] = subject |
---|
[1588] | 49 | args['continue'] = action_after_validate |
---|
[1575] | 50 | args['portal_status_message'] = psm |
---|
[1630] | 51 | if action_after_reject: |
---|
| 52 | url = context.absolute_url() + '/' + action_after_reject + '?' + urlencode(args) |
---|
[1606] | 53 | else: |
---|
| 54 | url = context.absolute_url() + '?' + urlencode(args) |
---|
[1575] | 55 | return REQUEST.RESPONSE.redirect(url) |
---|