1 | ## Script (Python) "validate_courses" |
---|
2 | ##bind container=container |
---|
3 | ##bind context=context |
---|
4 | ##bind namespace= |
---|
5 | ##bind script=script |
---|
6 | ##bind subpath=traverse_subpath |
---|
7 | ##parameters=student=None, action_after_reject=None, action_after_validate='' |
---|
8 | ##title= |
---|
9 | ## |
---|
10 | # $Id: getStudyCourseInfo.py 1504 2007-02-26 21:20:40Z henrik $ |
---|
11 | """ |
---|
12 | close the Students StudyLevel |
---|
13 | """ |
---|
14 | from Products.CMFCore.WorkflowCore import WorkflowException |
---|
15 | import DateTime |
---|
16 | current = DateTime.DateTime() |
---|
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 |
---|
28 | logger = logging.getLogger('Skins.validate_courses') |
---|
29 | |
---|
30 | wftool = context.portal_workflow |
---|
31 | students_folder = context.portal_url.getPortalObject().campus.students |
---|
32 | student_id = context.getStudentId() |
---|
33 | student = getattr(students_folder,student_id) |
---|
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,}) |
---|
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)) |
---|
44 | |
---|
45 | psm = 'portal_status_message=Course list validated!' |
---|
46 | url = context.absolute_url() + '/' + action_after_validate + '?' + psm |
---|
47 | return request.RESPONSE.redirect(url) |
---|