[1571] | 1 | ## Script (Python) "validate_courses" |
---|
[1513] | 2 | ##bind container=container |
---|
| 3 | ##bind context=context |
---|
| 4 | ##bind namespace= |
---|
| 5 | ##bind script=script |
---|
[1586] | 6 | ##bind subpath=traverse_subpath |
---|
[1853] | 7 | ##parameters=student=None, action_after_reject=None, action_after_validate='' |
---|
[1513] | 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 |
---|
[1612] | 15 | import DateTime |
---|
| 16 | current = DateTime.DateTime() |
---|
[1513] | 17 | try: |
---|
| 18 | from Products.zdb import set_trace |
---|
| 19 | except: |
---|
| 20 | def set_trace(): |
---|
| 21 | pass |
---|
| 22 | |
---|
| 23 | request = context.REQUEST |
---|
| 24 | mtool = context.portal_membership |
---|
| 25 | member = mtool.getAuthenticatedMember() |
---|
| 26 | member_id = str(member) |
---|
| 27 | import logging |
---|
[1571] | 28 | logger = logging.getLogger('Skins.validate_courses') |
---|
[1513] | 29 | |
---|
| 30 | wftool = context.portal_workflow |
---|
| 31 | students_folder = context.portal_url.getPortalObject().campus.students |
---|
[1589] | 32 | student_id = context.getStudentId() |
---|
| 33 | student = getattr(students_folder,student_id) |
---|
[1612] | 34 | level_doc = context.getContent() |
---|
| 35 | if level_doc.portal_type == 'StudentStudyLevel': |
---|
| 36 | level_doc.edit(mapping={'validated_by': member_id, |
---|
| 37 | 'validation_date': current,}) |
---|
[1589] | 38 | try: |
---|
| 39 | wftool.doActionFor(student,'validate_courses') |
---|
| 40 | except WorkflowException,E: |
---|
| 41 | logger.info('%s WorkflowException %s for %s' % (member_id,E,student_id)) |
---|
| 42 | return request.RESPONSE.redirect("%s" % context.absolute_url()) |
---|
| 43 | logger.info('%s validated course list of %s' % (member_id,student_id)) |
---|
[1575] | 44 | |
---|
| 45 | psm = 'portal_status_message=Course list validated!' |
---|
[1588] | 46 | url = context.absolute_url() + '/' + action_after_validate + '?' + psm |
---|
[1575] | 47 | return request.RESPONSE.redirect(url) |
---|