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 | try: |
---|
33 | context.portal_workflow.doActionFor(context,'open') |
---|
34 | except: |
---|
35 | pass |
---|
36 | |
---|
37 | is_valid, ds = course_doc.validate(request=REQUEST, |
---|
38 | schema_id = 'student_course_result', |
---|
39 | layout_id = 'student_course_result_fe', |
---|
40 | proxy=context, |
---|
41 | use_session=True) |
---|
42 | |
---|
43 | psm = "" |
---|
44 | args = {} |
---|
45 | action = "/course_edit_form" |
---|
46 | base_url = context.absolute_url() |
---|
47 | |
---|
48 | if is_valid: |
---|
49 | if cpsdocument_edit_button: |
---|
50 | #name = "%(firstname)s %(middlename)s %(lastname)s" % ds |
---|
51 | #name = name.strip() |
---|
52 | #name = name.replace(' ',' ') |
---|
53 | #email = ds.get('email') |
---|
54 | #phone = ds.get('phone') |
---|
55 | #student_id = context.getStudentId() |
---|
56 | #context.students_catalog.modifyRecord(id = student_id, |
---|
57 | # name = name, |
---|
58 | # email = email, |
---|
59 | # phone = phone, |
---|
60 | # sex = ds.get('sex'), |
---|
61 | # ) |
---|
62 | logger.info('%s (%s) edited course result data %s' % (info['id'],info['review_state'],context.id)) |
---|
63 | #action = "" |
---|
64 | #base_url = student.absolute_url() |
---|
65 | #url = base_url + action |
---|
66 | psm = 'psm_content_changed' |
---|
67 | else: |
---|
68 | psm = 'psm_content_error' |
---|
69 | args = getFormUidUrlArg(REQUEST) |
---|
70 | |
---|
71 | args['portal_status_message'] = psm |
---|
72 | url = base_url + action + '?' + urlencode(args) |
---|
73 | REQUEST.RESPONSE.redirect(url) |
---|