1 | ## Script (Python) "course_edit" |
---|
2 | ##bind container=container |
---|
3 | ##bind context=context |
---|
4 | ##bind namespace= |
---|
5 | ##bind script=script |
---|
6 | ##bind subpath=traverse_subpath |
---|
7 | ##parameters=REQUEST, cpsdocument_edit_button=None, cpsdocument_edit_and_view_button=None, action=None |
---|
8 | ##title= |
---|
9 | # $Id: course_edit.py 1071 2006-12-16 15:53:13Z joachim $ |
---|
10 | """ |
---|
11 | """ |
---|
12 | wf = context.portal_workflow |
---|
13 | from urllib import urlencode |
---|
14 | from Products.CPSDocument.utils import getFormUidUrlArg |
---|
15 | import DateTime |
---|
16 | current = DateTime.DateTime() |
---|
17 | import logging |
---|
18 | logger = logging.getLogger('Skins.course_edit') |
---|
19 | |
---|
20 | info = context.getCourseResultInfo() |
---|
21 | |
---|
22 | if info is None: |
---|
23 | logger.info('Anonymous user tried to access %s' % REQUEST.get('URL0')) |
---|
24 | return REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) |
---|
25 | |
---|
26 | student = info['student'] |
---|
27 | #per = info['per'] |
---|
28 | course_doc = info['course_doc'] |
---|
29 | state = info['review_state'] |
---|
30 | result_state = wf.getInfoFor(context,'review_state',None) |
---|
31 | if result_state == "closed": |
---|
32 | context.portal_workflow.doActionFor(context,'open') |
---|
33 | |
---|
34 | is_valid, ds = course_doc.validate(request=REQUEST, |
---|
35 | schema_id = 'student_course_result', |
---|
36 | layout_id = 'student_course_result_fe', |
---|
37 | proxy=context, |
---|
38 | use_session=True) |
---|
39 | |
---|
40 | psm = "" |
---|
41 | args = {} |
---|
42 | action = "/course_edit_form" |
---|
43 | base_url = context.absolute_url() |
---|
44 | |
---|
45 | if is_valid: |
---|
46 | if cpsdocument_edit_button: |
---|
47 | #name = "%(firstname)s %(middlename)s %(lastname)s" % ds |
---|
48 | #name = name.strip() |
---|
49 | #name = name.replace(' ',' ') |
---|
50 | #email = ds.get('email') |
---|
51 | #phone = ds.get('phone') |
---|
52 | #student_id = context.getStudentId() |
---|
53 | #context.students_catalog.modifyRecord(id = student_id, |
---|
54 | # name = name, |
---|
55 | # email = email, |
---|
56 | # phone = phone, |
---|
57 | # sex = ds.get('sex'), |
---|
58 | # ) |
---|
59 | logger.info('%s (%s) edited course result data %s' % (info['id'],info['review_state'],context.id)) |
---|
60 | #action = "" |
---|
61 | #base_url = student.absolute_url() |
---|
62 | #url = base_url + action |
---|
63 | psm = 'psm_content_changed' |
---|
64 | else: |
---|
65 | psm = 'psm_content_error' |
---|
66 | args = getFormUidUrlArg(REQUEST) |
---|
67 | |
---|
68 | args['portal_status_message'] = psm |
---|
69 | url = base_url + action + '?' + urlencode(args) |
---|
70 | REQUEST.RESPONSE.redirect(url) |
---|